Skip to content

Commit 543664a

Browse files
Use Uiautomate2options for caps object creation for w3c session
1 parent 416df3d commit 543664a

1 file changed

Lines changed: 21 additions & 17 deletions

File tree

android/browserstack_sample.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
from appium import webdriver
2+
from appium.options.android import UiAutomator2Options
23
from appium.webdriver.common.mobileby import MobileBy
34
from selenium.webdriver.support.ui import WebDriverWait
45
from selenium.webdriver.support import expected_conditions as EC
56
import time
67

7-
desired_cap = {
8-
# Set your access credentials
9-
"browserstack.user" : "YOUR_USERNAME",
10-
"browserstack.key" : "YOUR_ACCESS_KEY",
8+
# Options are only available since client version 2.3.0
9+
# If you use an older client then switch to desired_capabilities
10+
# instead: https://github.com/appium/python-client/pull/720
11+
options = UiAutomator2Options().load_capabilities({
12+
# Specify device and os_version for testing
13+
"platformName" : "android",
14+
"platformVersion" : "9.0",
15+
"deviceName" : "Google Pixel 3",
1116

1217
# Set URL of the application under test
13-
"app" : "bs://<app-id>",
18+
"app" : "<bs://app-id>",
1419

15-
# Specify device and os_version for testing
16-
"device" : "Google Pixel 3",
17-
"os_version" : "9.0",
18-
1920
# Set other BrowserStack capabilities
20-
"project" : "First Python project",
21-
"build" : "browserstack-build-1",
22-
"name" : "first_test"
23-
}
21+
'bstack:options' : {
22+
"projectName" : "First Python project",
23+
"buildName" : "browserstack-build-1",
24+
"sessionName" : "first_test",
25+
26+
# Set your access credentials
27+
"userName" : "YOUR_USERNAME",
28+
"accessKey" : "YOUR_ACCESS_KEY"
29+
}
30+
})
2431

2532
# Initialize the remote Webdriver using BrowserStack remote URL
2633
# and desired capabilities defined above
27-
driver = webdriver.Remote(
28-
command_executor="http://hub-cloud.browserstack.com/wd/hub",
29-
desired_capabilities=desired_cap
30-
)
34+
driver = webdriver.Remote("http://hub-cloud.browserstack.com/wd/hub", options=options)
3135

3236
# Test case for the BrowserStack sample Android app.
3337
# If you have uploaded your app, update the test case here.

0 commit comments

Comments
 (0)