|
1 | 1 | from appium import webdriver |
| 2 | +from appium.options.android import UiAutomator2Options |
2 | 3 | from appium.webdriver.common.mobileby import MobileBy |
3 | 4 | from selenium.webdriver.support.ui import WebDriverWait |
4 | 5 | from selenium.webdriver.support import expected_conditions as EC |
5 | 6 | import time |
6 | 7 |
|
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", |
11 | 16 |
|
12 | 17 | # Set URL of the application under test |
13 | | - "app" : "bs://<app-id>", |
| 18 | + "app" : "<bs://app-id>", |
14 | 19 |
|
15 | | - # Specify device and os_version for testing |
16 | | - "device" : "Google Pixel 3", |
17 | | - "os_version" : "9.0", |
18 | | - |
19 | 20 | # 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 | +}) |
24 | 31 |
|
25 | 32 | # Initialize the remote Webdriver using BrowserStack remote URL |
26 | 33 | # 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) |
31 | 35 |
|
32 | 36 | # Test case for the BrowserStack sample Android app. |
33 | 37 | # If you have uploaded your app, update the test case here. |
|
0 commit comments