Skip to content

Commit 284e6fc

Browse files
committed
Merge pull request #56 from Jonahss/master
removed complex_find, added get_settings, update_settings
2 parents 41a9297 + ee03b24 commit 284e6fc

File tree

4 files changed

+60
-34
lines changed

4 files changed

+60
-34
lines changed

Diff for: README.md

+27-15
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ assertIsNotNone(el)
362362
363363
#### Start an arbitrary activity
364364
365-
The `driver.start_activity` method opens arbitrary activities on a device.
366-
If the activity is not part of the application under test, it will also
365+
The `driver.start_activity` method opens arbitrary activities on a device.
366+
If the activity is not part of the application under test, it will also
367367
launch the activity's application.
368368
369369
```python
@@ -483,19 +483,6 @@ self.assertEqual(data, data_ret)
483483
```
484484

485485

486-
#### Complex find in Android
487-
488-
Appium supports a way to do complex searches for elements on an Android device.
489-
This is accessed through `driver.complex_find`. The arguments and use case,
490-
to borrow from Winston Churchill, remain a riddle, wrapped in a mystery, inside
491-
an enigma.
492-
493-
```python
494-
el = self.driver.complex_find([[[2, 'Ani']]])
495-
self.assertIsNotNone(el)
496-
```
497-
498-
499486
#### End test coverage
500487

501488
There is functionality in the Android emulator to instrument certain activities.
@@ -518,3 +505,28 @@ argument is the number of seconds to wait before unlocking.
518505
#### Shake the device
519506

520507
To shake the device, use `driver.shake`.
508+
509+
510+
#### Appium Settings
511+
512+
Settings are a new concept introduced by appium. They are currently not a part of the Mobile JSON Wire Protocol, or the Webdriver spec.
513+
514+
Settings are a way to specify the behavior of the appium server.
515+
516+
Settings are:
517+
518+
Mutable, they can be changed during a session
519+
Only relevant during the session they are applied. They are reset for each new session.
520+
Control the way the appium server behaves during test automation. They do not apply to controlling the app or device under test.
521+
522+
See [the docs](https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/settings.md) for more information.
523+
524+
To get settings:
525+
```python
526+
settings = driver.get_settings()
527+
```
528+
529+
To set settings:
530+
```python
531+
driver.update_settings({"some setting": "the value"})
532+
```

Diff for: appium/webdriver/mobilecommand.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class MobileCommand(object):
3838
PULL_FILE = 'pullFile'
3939
PULL_FOLDER = 'pullFolder'
4040
PUSH_FILE = 'pushFile'
41-
COMPLEX_FIND = 'complexFind'
4241
BACKGROUND = 'background'
4342
IS_APP_INSTALLED = 'isAppInstalled'
4443
INSTALL_APP = 'installApp'
@@ -52,3 +51,5 @@ class MobileCommand(object):
5251
HIDE_KEYBOARD = 'hideKeyboard'
5352
REPLACE_KEYS = 'replaceKeys'
5453
START_ACTIVITY = 'startActivity'
54+
GET_SETTINGS = 'getSettings'
55+
UPDATE_SETTINGS = 'updateSettings'

Diff for: appium/webdriver/webdriver.py

+22-13
Original file line numberDiff line numberDiff line change
@@ -457,17 +457,6 @@ def push_file(self, path, base64data):
457457
self.execute(Command.PUSH_FILE, data)
458458
return self
459459

460-
def complex_find(self, selector):
461-
"""Performs a find for elements in the current application.
462-
463-
:Args:
464-
- selector - an array of selection criteria
465-
"""
466-
data = {
467-
'selector': selector,
468-
}
469-
return self.execute(Command.COMPLEX_FIND, data)['value']
470-
471460
def background_app(self, seconds):
472461
"""Puts the application in the background on the device for a certain
473462
duration.
@@ -664,6 +653,24 @@ def active_ime_engine(self):
664653
"""
665654
return self.execute(Command.GET_ACTIVE_IME_ENGINE, {})['value']
666655

656+
def get_settings(self):
657+
"""Returns the appium server Settings for the current session.
658+
Do not get Settings confused with Desired Capabilities, they are
659+
separate concepts. See https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/settings.md
660+
"""
661+
return self.execute(Command.GET_SETTINGS, {})['value']
662+
663+
def update_settings(self, settings):
664+
"""Set settings for the current session.
665+
For more on settings, see: https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/settings.md
666+
667+
:Args:
668+
- settings - dictionary of settings to apply to the current test session
669+
"""
670+
data = {"settings": settings}
671+
672+
self.execute(Command.UPDATE_SETTINGS, data)
673+
return self
667674

668675
def _addCommands(self):
669676
self.command_executor._commands[Command.CONTEXTS] = \
@@ -695,8 +702,6 @@ def _addCommands(self):
695702
('POST', '/session/$sessionId/appium/device/pull_folder')
696703
self.command_executor._commands[Command.PUSH_FILE] = \
697704
('POST', '/session/$sessionId/appium/device/push_file')
698-
self.command_executor._commands[Command.COMPLEX_FIND] = \
699-
('POST', '/session/$sessionId/appium/app/complex_find')
700705
self.command_executor._commands[Command.BACKGROUND] = \
701706
('POST', '/session/$sessionId/appium/app/background')
702707
self.command_executor._commands[Command.IS_APP_INSTALLED] = \
@@ -739,6 +744,10 @@ def _addCommands(self):
739744
('GET', '/session/$sessionId/ime/active_engine')
740745
self.command_executor._commands[Command.REPLACE_KEYS] = \
741746
('POST', '/session/$sessionId/appium/element/$elementId/replace_value')
747+
self.command_executor._commands[Command.GET_SETTINGS] = \
748+
('GET', '/session/$sessionId/appium/settings')
749+
self.command_executor._commands[Command.UPDATE_SETTINGS] = \
750+
('POST', '/session/$sessionId/appium/settings')
742751

743752

744753
# monkeypatched method for WebElement

Diff for: test/functional/android/appium_tests.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ def test_pull_folder(self):
9393
myzip.read('1.txt')
9494
myzip.read('2.txt')
9595

96-
def test_complex_find(self):
97-
# this only works with a three dimensional array like here.
98-
el = self.driver.complex_find([[[2, 'Ani']]])
99-
self.assertIsNotNone(el)
100-
10196
def test_background_app(self):
10297
self.driver.background_app(1)
10398
sleep(5)
@@ -213,6 +208,15 @@ def _assert_activity_contains(self, activity):
213208
current = self.driver.current_activity()
214209
self.assertTrue(activity in current)
215210

211+
def test_get_settings(self):
212+
settings = self.driver.get_settings()
213+
self.assertIsNotNone(settings)
214+
215+
def test_update_settings(self):
216+
self.driver.update_settings({"cyberdelia": "open"})
217+
settings = self.driver.get_settings()
218+
self.assertEqual(settings["cyberdelia"], "open")
219+
216220
if __name__ == "__main__":
217221
suite = unittest.TestLoader().loadTestsFromTestCase(AppiumTests)
218222
unittest.TextTestRunner(verbosity=2).run(suite)

0 commit comments

Comments
 (0)