|
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 URL of the application under test |
9 | | - "app" : "bs://<app-id>", |
10 | | - |
| 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({ |
11 | 12 | # Specify device and os_version for testing |
12 | | - "deviceName": "Google Pixel 3", |
13 | | - "platformName": "android", |
14 | | - "platformVersion": "9.0", |
| 13 | + "platformName" : "android", |
| 14 | + "platformVersion" : "9.0", |
| 15 | + "deviceName" : "Google Pixel 3", |
| 16 | + |
| 17 | + # Set URL of the application under test |
| 18 | + "app" : "<bs://app-id>", |
15 | 19 |
|
16 | 20 | # Set other BrowserStack capabilities |
17 | | - "bstack:options": { |
18 | | - "userName" : "YOUR_USERNAME", |
19 | | - "accessKey" : "YOUR_ACCESS_KEY", |
| 21 | + 'bstack:options' : { |
20 | 22 | "projectName" : "First Python project", |
21 | 23 | "buildName" : "browserstack-build-1", |
22 | | - "sessionName" : "first_test" |
| 24 | + "sessionName" : "first_test", |
| 25 | + |
| 26 | + # Set your access credentials |
| 27 | + "userName" : "YOUR_USERNAME", |
| 28 | + "accessKey" : "YOUR_ACCESS_KEY" |
23 | 29 | } |
24 | | -} |
| 30 | +}) |
25 | 31 |
|
26 | 32 | # Initialize the remote Webdriver using BrowserStack remote URL |
27 | 33 | # and desired capabilities defined above |
28 | | -driver = webdriver.Remote( |
29 | | - command_executor="http://hub-cloud.browserstack.com/wd/hub", |
30 | | - desired_capabilities=desired_cap |
31 | | -) |
| 34 | +driver = webdriver.Remote("http://hub-cloud.browserstack.com/wd/hub", options=options) |
32 | 35 |
|
33 | 36 | # Test case for the BrowserStack sample Android app. |
34 | 37 | # If you have uploaded your app, update the test case here. |
|
0 commit comments