Skip to content

Commit a270cdd

Browse files
jlippsKazuCocoa
authored andcommitted
add custom locator strategy (#260)
1 parent 0add6f6 commit a270cdd

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

appium/webdriver/common/mobileby.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ class MobileBy(By):
2323
ANDROID_VIEWTAG = '-android viewtag'
2424
ACCESSIBILITY_ID = 'accessibility id'
2525
IMAGE = '-image'
26+
CUSTOM = '-custom'

appium/webdriver/webdriver.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def __init__(self, command_executor='http://127.0.0.1:4444/wd/hub',
110110
By.ANDROID_VIEWTAG = MobileBy.ANDROID_VIEWTAG
111111
By.ACCESSIBILITY_ID = MobileBy.ACCESSIBILITY_ID
112112
By.IMAGE = MobileBy.IMAGE
113+
By.CUSTOM = MobileBy.CUSTOM
113114

114115
def start_session(self, capabilities, browser_profile=None):
115116
"""
@@ -416,6 +417,34 @@ def find_elements_by_accessibility_id(self, accessibility_id):
416417
"""
417418
return self.find_elements(by=By.ACCESSIBILITY_ID, value=accessibility_id)
418419

420+
def find_element_by_custom(self, selector):
421+
"""Finds an element in conjunction with a custom element finding plugin
422+
423+
:Args:
424+
- selector - a string of the form "module:selector", where "module" is
425+
the shortcut name given in the customFindModules capability, and
426+
"selector" is the string that will be passed to the custom element
427+
finding plugin itself
428+
429+
:Usage:
430+
driver.find_element_by_custom("foo:bar")
431+
"""
432+
return self.find_element(by=By.CUSTOM, value=selector)
433+
434+
def find_elements_by_custom(self, selector):
435+
"""Finds elements in conjunction with a custom element finding plugin
436+
437+
:Args:
438+
- selector - a string of the form "module:selector", where "module" is
439+
the shortcut name given in the customFindModules capability, and
440+
"selector" is the string that will be passed to the custom element
441+
finding plugin itself
442+
443+
:Usage:
444+
driver.find_elements_by_custom("foo:bar")
445+
"""
446+
return self.find_elements(by=By.CUSTOM, value=selector)
447+
419448
def create_web_element(self, element_id):
420449
"""
421450
Creates a web element with the specified element_id.

0 commit comments

Comments
 (0)