Skip to content

Commit 80aefff

Browse files
Ankit098francisf
authored andcommitted
update: add SDk changes, remove extra files
1 parent b43b13f commit 80aefff

File tree

11 files changed

+95
-134
lines changed

11 files changed

+95
-134
lines changed

browserstack.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# =============================
2+
# Set BrowserStack Credentials
3+
# =============================
4+
# Add your BrowserStack userName and acccessKey here or set BROWSERSTACK_USERNAME and
5+
# BROWSERSTACK_ACCESS_KEY as env variables
6+
userName: YOUR_USERNAME
7+
accessKey: YOUR_ACCESS_KEY
8+
9+
# ======================
10+
# Organizing your tests
11+
# ======================
12+
# Use `projectName`, `buildName`, `name` capabilities to organise your tests
13+
# `name` is the name of your test sessions and is automatically picked from your
14+
# test name and doesn't need to be set manually when using BrowserStack SDK
15+
# `buildName` is used to name your CI/CD job or the execution of your test suite.
16+
# Ensure you add a dynamic identifier, like an incremental build number from your
17+
# CI/CD or timestamp at the end of every build; otherwise tests from different
18+
# executions will be grouped together on BrowserStack
19+
buildName: browserstack-build-1
20+
# Use `projectName` to set the name of your project. Example, Marketing Website
21+
projectName: BrowserStack Samples
22+
23+
# =======================================
24+
# Platforms (Browsers / Devices to test)
25+
# =======================================
26+
# Platforms object contains all the browser / device combinations you want to test on.
27+
# Entire list available here -> (https://www.browserstack.com/list-of-browsers-and-platforms/automate)
28+
platforms:
29+
- os: OS X
30+
osVersion: Big Sur
31+
browser: Chrome
32+
browserVersion: latest
33+
- os: Windows
34+
osVersion: 10
35+
browser: Edge
36+
browserVersion: latest
37+
- device: Samsung Galaxy S22 Ultra
38+
browserName: chrome # Try 'samsung' for Samsung browser
39+
osVersion: 12.0
40+
41+
# =======================
42+
# Parallels per Platform
43+
# =======================
44+
# The number of parallel threads to be used for each platform set.
45+
# BrowserStack's SDK runner will select the best strategy based on the configured value
46+
#
47+
# Example 1 - If you have configured 3 platforms and set `parallelsPerPlatform` as 2, a total of 6 (2 * 3) parallel threads will be used on BrowserStack
48+
#
49+
# Example 2 - If you have configured 1 platform and set `parallelsPerPlatform` as 5, a total of 5 (1 * 5) parallel threads will be used on BrowserStack
50+
parallelsPerPlatform: 1
51+
52+
# ==========================================
53+
# BrowserStack Local
54+
# (For localhost, staging/private websites)
55+
# ==========================================
56+
# Set browserStackLocal to true if your website under test is not accessible publicly over the internet
57+
# Learn more about how BrowserStack Local works here -> https://www.browserstack.com/docs/automate/selenium/local-testing-introduction
58+
browserstackLocal: true # <boolean> (Default false)
59+
# browserStackLocalOptions:
60+
# Options to be passed to BrowserStack local in-case of advanced configurations
61+
# localIdentifier: # <string> (Default: null) Needed if you need to run multiple instances of local.
62+
# forceLocal: true # <boolean> (Default: false) Set to true if you need to resolve all your traffic via BrowserStack Local tunnel.
63+
# Entire list of arguments availabe here -> https://www.browserstack.com/docs/automate/selenium/manage-incoming-connections
64+
65+
# ===================
66+
# Debugging features
67+
# ===================
68+
debug: false # <boolean> # Set to true if you need screenshots for every selenium command ran
69+
networkLogs: false # <boolean> Set to true to enable HAR logs capturing
70+
consoleLogs: errors # <string> Remote browser's console debug levels to be printed (Available levels: `disable`, `errors`, `warnings`, `info`, `verbose`, Default: errors)

config/Config.py

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,15 @@
11
import os
22

3-
common_caps = {
4-
"browserstack.user" : "BROWSERSTACK_USERNAME",
5-
"browserstack.key" : "BROWSERSTACK_ACCESS_KEY",
6-
"build" : "browserstack-build-1",
7-
"browserstack.debug" : "true"
8-
}
9-
103
envs = [{
11-
"os" : "Windows",
12-
"os_version" : "10",
13-
"browser" : "Chrome",
14-
"browser_version" : "latest"
4+
"browser": "Chrome",
155
},
16-
{
17-
"os" : "OS X",
18-
"os_version" : "Big Sur",
19-
"browser" : "Safari",
20-
"browser_version" : "latest"
6+
{
7+
"browser": "Safari",
218
},
22-
{
23-
"device" : "Samsung Galaxy S22",
24-
"os_version" : "12"
9+
{
10+
"browser": "Firefox",
2511
}]
2612

27-
def combine_caps(i):
28-
29-
username = os.environ.get("BROWSERSTACK_USERNAME")
30-
accesskey = os.environ.get("BROWSERSTACK_ACCESS_KEY")
31-
if username != None and accesskey != None:
32-
common_caps["browserstack.user"] = username
33-
common_caps["browserstack.key"] = accesskey
3413

35-
x = int(i)
36-
envs[x].update(common_caps)
37-
return envs[x]
14+
def get_test_caps(i):
15+
return envs[int(i)]

config/KeywordsFile.robot

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
*** Settings ***
22
Library SeleniumLibrary
3-
Library mark-test-status.py
43

54
*** Variables ***
6-
${remote_url}= https://hub.browserstack.com/wd/hub
5+
${remote_url}= http://localhost:4444/wd/hub
76

87
*** Keywords ***
98
Open Session
@@ -16,45 +15,17 @@ Close Session
1615
Add Implicit Wait
1716
set selenium implicit wait 5
1817

19-
Mark Test Status
20-
[Arguments] ${status} ${reason}
21-
TEST STATUS ${status} ${reason}
22-
2318
Get the page title
2419
get title
2520

26-
Click on Sign In
27-
click element id=signin
28-
29-
Enter Credentials
30-
[Arguments] ${username} ${password}
31-
input text css=#username input ${username}
32-
click element css= .css-1n7v3ny-option
33-
input text css=#password input ${password}
34-
click element css= .css-1n7v3ny-option
35-
36-
Click on Login
37-
click element id=login-btn
38-
39-
Verify username
40-
[Arguments] ${assert_username}
41-
${retrived_username}= get text css=.username
42-
run keyword if "${retrived_username}" == "${assert_username}" mark test status passed Username validated!
43-
run keyword if "${retrived_username}" != "${assert_username}" mark test status failed Username validation failed!
44-
element should contain css=.username ${assert_username}
45-
4621
Verify site content
4722
${site_content}= get text css=body
48-
run keyword if "${site_content}" == "Up and running" mark test status passed Site Content validated!
49-
run keyword if "${site_content}" != "Up and running" mark test status failed Site Content validation failed!
5023
element should contain css=body Up and running
5124

5225
Add first product to cart
5326
click element xpath=//*[@id="1"]/div[4]
5427

5528
Verify product is added to cart
5629
${product_name} get text xpath=//*[@id="1"]/p
57-
${product_incart} get text css=p.title
58-
run keyword if "${product_name}" == "${product_incart}" mark test status passed Correct product added!
59-
run keyword if "${product_name}" != "${product_incart}" mark test status failed Something went wrong!
30+
${product_incart} get text css=p.title
6031
element should contain css=p.title ${product_name}

config/manage-local-testing.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

config/mark-test-status.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ robotframework
22
robotframework-seleniumlibrary==5.1.3
33
robotframework-pabot
44
browserstack-local
5-
selenium==3.141.0
5+
selenium
6+
browserstack-sdk

tests/LocalTest.robot

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
*** Settings ***
2-
Library SeleniumLibrary
3-
Library Collections
4-
Library ../config/manage-local-testing.py
2+
Library SeleniumLibrary
53
Library ../config/Config.py
6-
Resource ../config/KeywordsFile.robot
7-
Test Setup Setup for local test
8-
Test Teardown Teardown for local test
4+
Resource ../config/KeywordsFile.robot
5+
Test Setup Execute local test
6+
Test Teardown Close Session
97

108
*** Variables ***
11-
${local_url}= http://bs-local.com:45691/check
9+
${local_website_url}= http://bs-local.com:45691/check
1210

1311
*** Keywords ***
14-
Setup for local test
15-
START LOCAL
16-
${final_caps}= combine caps 0
17-
Set to Dictionary ${final_caps} name=BStack Demo - ${TEST NAME} browserstack.local=true
18-
Open Session ${final_caps} ${local_url}
19-
20-
Teardown for local test
21-
Close Session
22-
STOP LOCAL
12+
Execute local test
13+
${test_caps}= get test caps 0
14+
Open Session ${test_caps} ${local_website_url}
2315

2416
*** Test Cases ***
2517
Local Test

tests/parallel/Suite01.robot

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
*** Settings ***
22
Library SeleniumLibrary
3-
Library Collections
43
Library ../../config/Config.py
54
Resource ../../config/KeywordsFile.robot
65
Resource ../testcases.robot
@@ -12,14 +11,10 @@ ${website_url}= https://bstackdemo.com
1211

1312
*** Keywords ***
1413
Execute test
15-
${final_caps}= combine caps 0
16-
Set to Dictionary ${final_caps} name=BStack Demo - ${TEST NAME}
17-
Open Session ${final_caps} ${website_url}
14+
${test_caps}= get test caps 0
15+
Open Session ${test_caps} ${website_url}
1816

1917

2018
*** Test Cases ***
21-
Login Test
22-
Login
23-
2419
Add to Cart Test
2520
Add to Cart

tests/parallel/Suite02.robot

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
*** Settings ***
22
Library SeleniumLibrary
3-
Library Collections
43
Library ../../config/Config.py
54
Resource ../../config/KeywordsFile.robot
65
Resource ../testcases.robot
@@ -12,14 +11,10 @@ ${website_url}= https://bstackdemo.com
1211

1312
*** Keywords ***
1413
Execute test
15-
${final_caps}= combine caps 1
16-
Set to Dictionary ${final_caps} name=BStack Demo - ${TEST NAME}
17-
Open Session ${final_caps} ${website_url}
14+
${test_caps}= get test caps 1
15+
Open Session ${test_caps} ${website_url}
1816

1917

2018
*** Test Cases ***
21-
Login Test
22-
Login
23-
2419
Add to Cart Test
2520
Add to Cart

tests/parallel/Suite03.robot

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
*** Settings ***
22
Library SeleniumLibrary
3-
Library Collections
43
Library ../../config/Config.py
54
Resource ../../config/KeywordsFile.robot
65
Resource ../testcases.robot
@@ -12,14 +11,10 @@ ${website_url}= https://bstackdemo.com
1211

1312
*** Keywords ***
1413
Execute test
15-
${final_caps}= combine caps 2
16-
Set to Dictionary ${final_caps} name=BStack Demo - ${TEST NAME}
17-
Open Session ${final_caps} ${website_url}
14+
${test_caps}= get test caps 2
15+
Open Session ${test_caps} ${website_url}
1816

1917

2018
*** Test Cases ***
21-
Login Test
22-
Login
23-
2419
Add to Cart Test
2520
Add to Cart

0 commit comments

Comments
 (0)