Skip to content

Commit d980d8c

Browse files
Abizer Singaporewalafrancisf
authored andcommitted
Added support for Selenium 4 - W3C
1 parent b43b13f commit d980d8c

8 files changed

Lines changed: 35 additions & 28 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github)
3939

4040
## Notes
41-
* This repository only works for Selenium 3 as of now. Desired Capabilities do not get honoured for Selenium 4. The open issue on SeleniumLibrary can be found [here](https://github.com/robotframework/SeleniumLibrary/issues/1774).
41+
* This repository is for Selenium 4 - W3C protocol.
4242
* You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate)
4343
* To test on a different set of browsers, check out our [platform configurator](https://www.browserstack.com/automate/capabilities)
4444

config/Config.py

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,47 @@
11
import os
2+
from selenium import webdriver
3+
4+
options = webdriver.ChromeOptions()
5+
6+
browsers = ["Chrome", "Safari", "Chrome"]
27

38
common_caps = {
4-
"browserstack.user" : "BROWSERSTACK_USERNAME",
5-
"browserstack.key" : "BROWSERSTACK_ACCESS_KEY",
6-
"build" : "browserstack-build-1",
7-
"browserstack.debug" : "true"
9+
"userName" : "BROWSERSTACK_USERNAME",
10+
"accessKey" : "BROWSERSTACK_ACCESS_KEY",
11+
"buildName" : "browserstack-build-1",
12+
"debug" : "true"
813
}
914

1015
envs = [{
1116
"os" : "Windows",
12-
"os_version" : "10",
13-
"browser" : "Chrome",
14-
"browser_version" : "latest"
17+
"osVersion" : "10",
1518
},
1619
{
1720
"os" : "OS X",
18-
"os_version" : "Big Sur",
19-
"browser" : "Safari",
20-
"browser_version" : "latest"
21+
"osVersion" : "Big Sur",
2122
},
2223
{
23-
"device" : "Samsung Galaxy S22",
24-
"os_version" : "12"
24+
"deviceName" : "Samsung Galaxy S22",
25+
"osVersion" : "12"
2526
}]
2627

27-
def combine_caps(i):
28+
def combine_caps(i, session_name):
2829

2930
username = os.environ.get("BROWSERSTACK_USERNAME")
3031
accesskey = os.environ.get("BROWSERSTACK_ACCESS_KEY")
3132
if username != None and accesskey != None:
32-
common_caps["browserstack.user"] = username
33-
common_caps["browserstack.key"] = accesskey
33+
common_caps["userName"] = username
34+
common_caps["accessKey"] = accesskey
3435

3536
x = int(i)
3637
envs[x].update(common_caps)
37-
return envs[x]
38+
envs[x].update({"sessionName" : "BStack Demo - " + session_name})
39+
40+
if session_name == "Local Test":
41+
envs[x].update({"local" : "true"})
42+
43+
options.set_capability("browserName", browsers[x])
44+
options.set_capability("browserVersion", "latest")
45+
46+
options.set_capability("bstack:options", envs[x])
47+
return options

config/KeywordsFile.robot

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ ${remote_url}= https://hub.browserstack.com/wd/hub
88
*** Keywords ***
99
Open Session
1010
[Arguments] ${capabilities} ${test_url}
11-
open browser remote_url=${remote_url} desired_capabilities=${capabilities} url=${test_url}
11+
Create Webdriver Remote options=${capabilities} command_executor=${remote_url}
12+
Go To ${test_url}
1213

1314
Close Session
1415
close browser

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
robotframework
2-
robotframework-seleniumlibrary==5.1.3
2+
robotframework-seleniumlibrary==6.0.0
33
robotframework-pabot
44
browserstack-local
5-
selenium==3.141.0
5+
selenium==4.3.0

tests/LocalTest.robot

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ ${local_url}= http://bs-local.com:45691/check
1313
*** Keywords ***
1414
Setup for local test
1515
START LOCAL
16-
${final_caps}= combine caps 0
17-
Set to Dictionary ${final_caps} name=BStack Demo - ${TEST NAME} browserstack.local=true
16+
${final_caps}= combine caps 0 ${TEST NAME}
1817
Open Session ${final_caps} ${local_url}
1918

2019
Teardown for local test

tests/parallel/Suite01.robot

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ ${website_url}= https://bstackdemo.com
1212

1313
*** Keywords ***
1414
Execute test
15-
${final_caps}= combine caps 0
16-
Set to Dictionary ${final_caps} name=BStack Demo - ${TEST NAME}
15+
${final_caps}= combine caps 0 ${TEST NAME}
1716
Open Session ${final_caps} ${website_url}
1817

1918

tests/parallel/Suite02.robot

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ ${website_url}= https://bstackdemo.com
1212

1313
*** Keywords ***
1414
Execute test
15-
${final_caps}= combine caps 1
16-
Set to Dictionary ${final_caps} name=BStack Demo - ${TEST NAME}
15+
${final_caps}= combine caps 1 ${TEST NAME}
1716
Open Session ${final_caps} ${website_url}
1817

1918

tests/parallel/Suite03.robot

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ ${website_url}= https://bstackdemo.com
1212

1313
*** Keywords ***
1414
Execute test
15-
${final_caps}= combine caps 2
16-
Set to Dictionary ${final_caps} name=BStack Demo - ${TEST NAME}
15+
${final_caps}= combine caps 2 ${TEST NAME}
1716
Open Session ${final_caps} ${website_url}
1817

1918

0 commit comments

Comments
 (0)