@@ -104,37 +104,38 @@ environment:
104
104
105
105
` ` ` python
106
106
# Android environment
107
- import unittest
108
107
from appium import webdriver
108
+ # Options are only available since client version 2.3.0
109
+ # If you use an older client then switch to desired_capabilities
110
+ # instead: https://github.com/appium/python-client/pull/720
111
+ from appium.options.android import UiAutomator2Options
109
112
from appium.webdriver.common.appiumby import AppiumBy
110
113
111
- desired_caps = dict(
112
- platformName=' Android' ,
113
- platformVersion=' 10' ,
114
- automationName=' uiautomator2' ,
115
- deviceName=' Android Emulator' ,
116
- app=PATH(' ../../../apps/selendroid-test-app.apk' )
117
- )
118
- self.driver = webdriver.Remote(' http://localhost:4723/wd/hub' , desired_caps)
114
+ options = UiAutomator2Options ().\
115
+ set_capability(' platformVersion' , ' 10' ).\
116
+ set_capability(' deviceName' , ' Android Emulator' ).\
117
+ set_capability(' app' , PATH(' ../../../apps/selendroid-test-app.apk' ))
118
+ # Appium1 points to http://127.0.0.1:4723/wd/hub by default
119
+ self.driver = webdriver.Remote(' http://127.0.0.1:4723' , options=options)
119
120
el = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value=' item' )
120
121
el.click ()
121
122
` ` `
122
123
123
124
` ` ` python
124
125
# iOS environment
125
- import unittest
126
126
from appium import webdriver
127
+ # Options are only available since client version 2.3.0
128
+ # If you use an older client then switch to desired_capabilities
129
+ # instead: https://github.com/appium/python-client/pull/720
130
+ from appium.options.ios import XCUITestOptions
127
131
from appium.webdriver.common.appiumby import AppiumBy
128
132
129
- desired_caps = dict(
130
- platformName=' iOS' ,
131
- platformVersion=' 13.4' ,
132
- automationName=' xcuitest' ,
133
- deviceName=' iPhone Simulator' ,
134
- app=PATH(' ../../apps/UICatalog.app.zip' )
135
- )
136
-
137
- self.driver = webdriver.Remote(' http://localhost:4723/wd/hub' , desired_caps)
133
+ options = XCUITestOptions ().\
134
+ set_capability(' platformVersion' , ' 13.4' ).\
135
+ set_capability(' deviceName' , ' iPhone Simulator' ).\
136
+ set_capability(' app' , PATH(' ../../apps/UICatalog.app.zip' ))
137
+ # Appium1 points to http://127.0.0.1:4723/wd/hub by default
138
+ self.driver = webdriver.Remote(' http://127.0.0.1:4723' , options=options)
138
139
el = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value=' item' )
139
140
el.click ()
140
141
` ` `
@@ -151,37 +152,44 @@ If your Selenium/Appium server decorates the new session capabilities response w
151
152
Then python client will switch its endpoint to the one specified by the values of those keys.
152
153
153
154
` ` ` python
154
- import unittest
155
155
from appium import webdriver
156
-
157
- desired_caps = dict(
158
- platformName=' iOS' ,
159
- platformVersion=' 13.4' ,
160
- automationName=' xcuitest' ,
161
- deviceName=' iPhone Simulator' ,
162
- app=PATH(' ../../apps/UICatalog.app.zip' )
156
+ # Options are only available since client version 2.3.0
157
+ # If you use an older client then switch to desired_capabilities
158
+ # instead: https://github.com/appium/python-client/pull/720
159
+ from appium.options.ios import XCUITestOptions
160
+
161
+ options = XCUITestOptions ().load_capabilities({
162
+ ' platformVersion' : ' 13.4' ,
163
+ ' deviceName' : ' iPhone Simulator' ,
164
+ ' app' : PATH(' ../../apps/UICatalog.app.zip' ),
165
+ })
166
+
167
+ self.driver = webdriver.Remote(
168
+ # Appium1 points to http://127.0.0.1:4723/wd/hub by default
169
+ ' http://127.0.0.1:4723' ,
170
+ options=options,
171
+ direct_connection=True
163
172
)
164
-
165
- self.driver = webdriver.Remote(' http://localhost:4723/wd/hub' , desired_caps, direct_connection=True)
166
173
` ` `
167
174
168
175
# # Relax SSL validation
169
176
170
177
` strict_ssl` option allows you to send commands to an invalid certificate host like a self-signed one.
171
178
172
179
` ` ` python
173
- import unittest
174
180
from appium import webdriver
175
-
176
- desired_caps = dict(
177
- platformName=' iOS' ,
178
- platformVersion=' 13.4' ,
179
- automationName=' xcuitest' ,
180
- deviceName=' iPhone Simulator' ,
181
- app=PATH(' ../../apps/UICatalog.app.zip' )
182
- )
183
-
184
- self.driver = webdriver.Remote(' http://localhost:4723/wd/hub' , desired_caps, strict_ssl=False)
181
+ # Options are only available since client version 2.3.0
182
+ # If you use an older client then switch to desired_capabilities
183
+ # instead: https://github.com/appium/python-client/pull/720
184
+ from appium.options.common import AppiumOptions
185
+
186
+ options = AppiumOptions ()
187
+ options.platform_name = ' mac'
188
+ options.automation_name = ' safari'
189
+ options.set_capability(' browser_name' , ' safari' )
190
+
191
+ # Appium1 points to http://127.0.0.1:4723/wd/hub by default
192
+ self.driver = webdriver.Remote(' http://127.0.0.1:4723' , options=options, strict_ssl=False)
185
193
` ` `
186
194
187
195
# # Documentation
0 commit comments