webdriver.extensions.search_context package¶
Submodules¶
webdriver.extensions.search_context.android module¶
-
class
webdriver.extensions.search_context.android.
AndroidSearchContext
¶ Bases:
webdriver.extensions.search_context.base_search_context.BaseSearchContext
Define search context for Android
-
find_element_by_android_data_matcher
(name: Optional[str] = None, args: Optional[str] = None, className: Optional[str] = None) → WebElement¶ Finds element by [onData](https://medium.com/androiddevelopers/adapterviews-and-espresso-f4172aa853cf) in Android
It works with [Espresso Driver](https://github.com/appium/appium-espresso-driver).
- Parameters
name (
str
, optional) – The name of a method to invoke. The method must return a Hamcrest [Matcher](http://hamcrest.org/JavaHamcrest/javadoc/1.3/org/hamcrest/Matcher.html)args (
str
, optional) – The args provided to the methodclassName (
str
, optional) – The class name that the method is part of (defaults to org.hamcrest.Matchers). Can be fully qualified, or simple, and simple defaults to androidx.test.espresso.matcher package (e.g.: class=CursorMatchers fully qualified is class=androidx.test.espresso.matcher.CursorMatchers
- Returns
The found element
- Return type
appium.webdriver.webelement.WebElement
- Raises
TypeError - Raises a TypeError if the arguments are not validated for JSON format –
- Usage:
driver.find_element_by_android_data_matcher(name=’hasEntry’, args=[‘title’, ‘Animation’])
# To enable auto completion in PyCharm(IDE) :rtype: appium.webdriver.webelement.WebElement
-
find_element_by_android_uiautomator
(uia_string: str) → WebElement¶ Finds element by uiautomator in Android.
- Parameters
uia_string – The element name in the Android UIAutomator library
- Usage:
driver.find_element_by_android_uiautomator(‘.elements()[1].cells()[2]’)
- Returns
appium.webdriver.webelement.WebElement
- Return type
appium.webdriver.webelement.WebElement
-
find_element_by_android_viewtag
(tag: str) → WebElement¶ Finds element by [View#tags](https://developer.android.com/reference/android/view/View#tags) in Android.
It works with [Espresso Driver](https://github.com/appium/appium-espresso-driver).
- Parameters
tag (str) – The tag name of the view to look for
- Usage:
driver.find_element_by_android_viewtag(‘a tag name’)
- Returns
appium.webdriver.webelement.WebElement
- Return type
appium.webdriver.webelement.WebElement
-
find_elements_by_android_data_matcher
(name: Optional[str] = None, args: Optional[str] = None, className: Optional[str] = None) → List[WebElement]¶ Finds elements by [onData](https://medium.com/androiddevelopers/adapterviews-and-espresso-f4172aa853cf) in Android It works with [Espresso Driver](https://github.com/appium/appium-espresso-driver).
- Parameters
name (
str
, optional) – The name of a method to invoke. The method must return a Hamcrest [Matcher](http://hamcrest.org/JavaHamcrest/javadoc/1.3/org/hamcrest/Matcher.html)args (
str
, optional) – The args provided to the methodclassName (
str
, optional) – The class name that the method is part of (defaults to org.hamcrest.Matchers). Can be fully qualified, or simple, and simple defaults to androidx.test.espresso.matcher package (e.g.: class=CursorMatchers fully qualified is class=androidx.test.espresso.matcher.CursorMatchers
- Returns
The found elements
- Return type
appium.webdriver.webelement.WebElement
- Usage:
driver.find_elements_by_android_data_matcher(name=’hasEntry’, args=[‘title’, ‘Animation’])
- Return type
appium.webdriver.webelement.WebElement
-
find_elements_by_android_uiautomator
(uia_string: str) → List[WebElement]¶ Finds elements by uiautomator in Android.
- Parameters
uia_string (str) – The element name in the Android UIAutomator library
- Usage:
driver.find_elements_by_android_uiautomator(‘.elements()[1].cells()[2]’)
- Returns
list
ofappium.webdriver.webelement.WebElement
- Return type
list of appium.webdriver.webelement.WebElement
-
find_elements_by_android_viewtag
(tag: str) → List[WebElement]¶ Finds element by [View#tags](https://developer.android.com/reference/android/view/View#tags) in Android.
It works with [Espresso Driver](https://github.com/appium/appium-espresso-driver).
- Parameters
tag (str) – The tag name of the view to look for
- Usage:
driver.find_elements_by_android_viewtag(‘a tag name’)
- Returns
list
ofappium.webdriver.webelement.WebElement
- Return type
list of appium.webdriver.webelement.WebElement
-
webdriver.extensions.search_context.base_search_context module¶
-
class
webdriver.extensions.search_context.base_search_context.
BaseSearchContext
¶ Bases:
object
Used by each search context. Dummy find_element/s are for preventing pylint error
-
find_element
(by: str, value: Union[str, Dict] = None) → WebElement¶
-
find_elements
(by: str, value: Union[str, Dict] = None) → List[WebElement]¶
-
webdriver.extensions.search_context.custom module¶
-
class
webdriver.extensions.search_context.custom.
CustomSearchContext
¶ Bases:
webdriver.extensions.search_context.base_search_context.BaseSearchContext
Define search context for custom plugin
-
find_element_by_custom
(selector: str) → WebElement¶ Finds an element in conjunction with a custom element finding plugin
- Parameters
selector (str) – a string of the form “module:selector”, where “module” is the shortcut name given in the customFindModules capability, and “selector” is the string that will be passed to the custom element finding plugin itself
- Usage:
driver.find_element_by_custom(“foo:bar”)
- Returns
appium.webdriver.webelement.WebElement
# To enable auto completion in PyCharm(IDE) :rtype: appium.webdriver.webelement.WebElement
-
find_elements_by_custom
(selector: str) → List[WebElement]¶ Finds elements in conjunction with a custom element finding plugin
- Parameters
selector – a string of the form “module:selector”, where “module” is the shortcut name given in the customFindModules capability, and “selector” is the string that will be passed to the custom element finding plugin itself
- Usage:
driver.find_elements_by_custom(“foo:bar”)
- Returns
list
ofappium.webdriver.webelement.WebElement
- Return type
list of appium.webdriver.webelement.WebElement
-
webdriver.extensions.search_context.ios module¶
-
class
webdriver.extensions.search_context.ios.
iOSSearchContext
¶ Bases:
webdriver.extensions.search_context.base_search_context.BaseSearchContext
Define search context for iOS
-
find_element_by_ios_class_chain
(class_chain_string: str) → WebElement¶ Find an element by ios class chain string.
- Parameters
class_chain_string (str) – The class chain string
- Usage:
driver.find_element_by_ios_class_chain(‘XCUIElementTypeWindow/XCUIElementTypeButton[3]’)
- Returns
appium.webdriver.webelement.WebElement
- Return type
appium.webdriver.webelement.WebElement
-
find_element_by_ios_predicate
(predicate_string: str) → WebElement¶ Find an element by ios predicate string.
- Parameters
predicate_string (str) – The predicate string
- Usage:
driver.find_element_by_ios_predicate(‘label == “myLabel”’)
- Returns
appium.webdriver.webelement.WebElement
- Return type
appium.webdriver.webelement.WebElement
-
find_element_by_ios_uiautomation
(uia_string: str) → WebElement¶ Finds an element by uiautomation in iOS.
- Parameters
uia_string (str) – The element name in the iOS UIAutomation library
- Usage:
driver.find_element_by_ios_uiautomation(‘.elements()[1].cells()[2]’)
- Returns
appium.webdriver.webelement.WebElement
# To enable auto completion in PyCharm(IDE) :rtype: appium.webdriver.webelement.WebElement
-
find_elements_by_ios_class_chain
(class_chain_string: str) → List[WebElement]¶ Finds elements by ios class chain string.
- Parameters
class_chain_string (str) – The class chain string
- Usage:
driver.find_elements_by_ios_class_chain(‘XCUIElementTypeWindow[2]/XCUIElementTypeAny[-2]’)
- Returns
list
ofappium.webdriver.webelement.WebElement
- Return type
list of appium.webdriver.webelement.WebElement
-
find_elements_by_ios_predicate
(predicate_string: str) → List[WebElement]¶ Finds elements by ios predicate string.
- Parameters
predicate_string (str) – The predicate string
- Usage:
driver.find_elements_by_ios_predicate(‘label == “myLabel”’)
- Returns
list
ofappium.webdriver.webelement.WebElement
- Return type
list of appium.webdriver.webelement.WebElement
-
find_elements_by_ios_uiautomation
(uia_string: str) → List[WebElement]¶ Finds elements by uiautomation in iOS.
- Parameters
uia_string (str) – The element name in the iOS UIAutomation library
- Usage:
driver.find_elements_by_ios_uiautomation(‘.elements()[1].cells()[2]’)
- Returns
list
ofappium.webdriver.webelement.WebElement
- Return type
list of appium.webdriver.webelement.WebElement
-
webdriver.extensions.search_context.mobile module¶
-
class
webdriver.extensions.search_context.mobile.
MobileSearchContext
¶ Bases:
webdriver.extensions.search_context.base_search_context.BaseSearchContext
Define search context for Mobile(Android, iOS)
-
find_element_by_accessibility_id
(accessibility_id: str) → WebElement¶ Finds an element by accessibility id.
- Parameters
accessibility_id (str) – A string corresponding to a recursive element search using the Id/Name that the native Accessibility options utilize
- Usage:
driver.find_element_by_accessibility_id()
- Returns
appium.webdriver.webelement.WebElement
# To enable auto completion in PyCharm(IDE) :rtype: appium.webdriver.webelement.WebElement
-
find_element_by_image
(img_path: str) → WebElement¶ Finds a portion of a screenshot by an image.
Uses driver.find_image_occurrence under the hood.
- Parameters
img_path (str) – a string corresponding to the path of a image
- Returns
appium.webdriver.webelement.WebElement
- Return type
appium.webdriver.webelement.WebElement
-
find_elements_by_accessibility_id
(accessibility_id: str) → List[WebElement]¶ Finds elements by accessibility id.
- Parameters
accessibility_id (str) – a string corresponding to a recursive element search using the Id/Name that the native Accessibility options utilize
- Usage:
driver.find_elements_by_accessibility_id()
- Returns
list
ofappium.webdriver.webelement.WebElement
- Return type
list of appium.webdriver.webelement.WebElement
-
find_elements_by_image
(img_path: str) → List[WebElement]¶ Finds a portion of a screenshot by an image.
Uses driver.find_image_occurrence under the hood. Note that this will only ever return at most one element
- Parameters
img_path (str) – a string corresponding to the path of a image
- Returns
list
ofappium.webdriver.webelement.WebElement
- Return type
list of appium.webdriver.webelement.WebElement
-
webdriver.extensions.search_context.windows module¶
-
class
webdriver.extensions.search_context.windows.
WindowsSearchContext
¶ Bases:
webdriver.extensions.search_context.base_search_context.BaseSearchContext
Define search context for Windows
-
find_element_by_windows_uiautomation
(win_uiautomation: str) → WebElement¶ Finds an element by windows uiautomation
- Parameters
win_uiautomation (str) – The element name in the windows UIAutomation selector
- Usage:
driver.find_element_by_windows_uiautomation()
- Returns
appium.webdriver.webelement.WebElement
# To enable auto completion in PyCharm(IDE) :rtype: appium.webdriver.webelement.WebElement
-
find_elements_by_windows_uiautomation
(win_uiautomation: str) → List[WebElement]¶ Finds elements by windows uiautomation
- Parameters
win_uiautomation (str) – The element name in the windows UIAutomation selector
- Usage:
driver.find_elements_by_windows_uiautomation()
- Returns
list
ofappium.webdriver.webelement.WebElement
- Return type
list of appium.webdriver.webelement.WebElement
-
Module contents¶
-
class
webdriver.extensions.search_context.
AppiumSearchContext
(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=None, browser_profile=None, proxy=None, keep_alive=False, file_detector=None, options=None)¶ Bases:
selenium.webdriver.remote.webdriver.WebDriver
,webdriver.extensions.search_context.android.AndroidSearchContext
,webdriver.extensions.search_context.custom.CustomSearchContext
,webdriver.extensions.search_context.ios.iOSSearchContext
,webdriver.extensions.search_context.mobile.MobileSearchContext
,webdriver.extensions.search_context.windows.WindowsSearchContext
Returns appium driver search conext
-
class
webdriver.extensions.search_context.
AppiumWebElementSearchContext
(parent, id_, w3c=False)¶ Bases:
selenium.webdriver.remote.webelement.WebElement
,webdriver.extensions.search_context.android.AndroidSearchContext
,webdriver.extensions.search_context.custom.CustomSearchContext
,webdriver.extensions.search_context.ios.iOSSearchContext
,webdriver.extensions.search_context.mobile.MobileSearchContext
,webdriver.extensions.search_context.windows.WindowsSearchContext
Returns appium web element search context