appium.webdriver.extensions.search_context package
Submodules
appium.webdriver.extensions.search_context.android module
- class AndroidSearchContext
Bases:
appium.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[Any] = 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 – 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 – The args provided to the method
className – 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’])
- 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
The found element
- Return type
appium.webdriver.webelement.WebElement
- find_element_by_android_view_matcher(name: Optional[str] = None, args: Optional[Any] = None, className: Optional[str] = None) WebElement
Finds element by [onView](https://developer.android.com/training/testing/espresso/basics) in Android
It works with [Espresso Driver](https://github.com/appium/appium-espresso-driver).
- Parameters
name – 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 – The args provided to the method
className – The class name that the method is part of (defaults to org.hamcrest.Matchers). Can be fully qualified by having the androidx.test.espresso.matcher. prefix. If the prefix is not provided then it is going to be added implicitly. (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_view_matcher(name=’withText’, args=[‘Accessibility’], className=’ViewMatchers’)
- 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 – The tag name of the view to look for
- Usage:
driver.find_element_by_android_viewtag(‘a tag name’)
- Returns
The found element
- Return type
appium.webdriver.webelement.WebElement
- find_elements_by_android_data_matcher(name: Optional[str] = None, args: Optional[Any] = 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 – 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 – The args provided to the method
className – 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’])
- find_elements_by_android_uiautomator(uia_string: str) List[WebElement]
Finds elements by uiautomator in Android.
- Parameters
uia_string – The element name in the Android UIAutomator library
- Usage:
driver.find_elements_by_android_uiautomator(‘.elements()[1].cells()[2]’)
- Returns
The found elements
- Return type
- 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 – The tag name of the view to look for
- Usage:
driver.find_elements_by_android_viewtag(‘a tag name’)
- Returns
The found elements
- Return type
appium.webdriver.extensions.search_context.base_search_context module
appium.webdriver.extensions.search_context.custom module
- class CustomSearchContext
Bases:
appium.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 – 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
The found element
- Return type
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
The found elements
- Return type
appium.webdriver.extensions.search_context.ios module
- class iOSSearchContext
Bases:
appium.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 – The class chain string
- Usage:
driver.find_element_by_ios_class_chain(‘XCUIElementTypeWindow/XCUIElementTypeButton[3]’)
- Returns
The found element
- 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 – The predicate string
- Usage:
driver.find_element_by_ios_predicate(‘label == “myLabel”’)
- Returns
The found element
- 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 – The element name in the iOS UIAutomation library
- Usage:
driver.find_element_by_ios_uiautomation(‘.elements()[1].cells()[2]’)
- Returns
The found element
- Return type
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 – The class chain string
- Usage:
driver.find_elements_by_ios_class_chain(‘XCUIElementTypeWindow[2]/XCUIElementTypeAny[-2]’)
- Returns
The found elements
- Return type
- find_elements_by_ios_predicate(predicate_string: str) List[WebElement]
Finds elements by ios predicate string.
- Parameters
predicate_string – The predicate string
- Usage:
driver.find_elements_by_ios_predicate(‘label == “myLabel”’)
- Returns
The found elements
- Return type
- find_elements_by_ios_uiautomation(uia_string: str) List[WebElement]
Finds elements by uiautomation in iOS.
- Parameters
uia_string – The element name in the iOS UIAutomation library
- Usage:
driver.find_elements_by_ios_uiautomation(‘.elements()[1].cells()[2]’)
- Returns
The found elements
- Return type
appium.webdriver.extensions.search_context.mobile module
- class MobileSearchContext
Bases:
appium.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 – 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
The found element
- Return type
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 – a string corresponding to the path of a image
- Returns
The found element
- Return type
appium.webdriver.webelement.WebElement
- find_elements_by_accessibility_id(accessibility_id: str) List[WebElement]
Finds elements by accessibility id.
- Parameters
accessibility_id – 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
The found elements
- Return type
- 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 – a string corresponding to the path of a image
- Returns
The found elements
- Return type
appium.webdriver.extensions.search_context.windows module
- class WindowsSearchContext
Bases:
appium.webdriver.extensions.search_context.base_search_context.BaseSearchContext
Define search context for Windows
- find_element_by_windows_uiautomation(win_uiautomation: str) WebElement
[Deprecated] Finds an element by windows uiautomation
- Parameters
win_uiautomation – The element name in the windows UIAutomation selector
- Usage:
driver.find_element_by_windows_uiautomation()
- Returns
The found element
- Return type
appium.webdriver.webelement.WebElement
- find_elements_by_windows_uiautomation(win_uiautomation: str) List[WebElement]
[Deprecated] Finds elements by windows uiautomation
- Parameters
win_uiautomation – The element name in the windows UIAutomation selector
- Usage:
driver.find_elements_by_windows_uiautomation()
- Returns
The found elements
- Return type
Module contents
- class AppiumSearchContext(command_executor='http://127.0.0.1:4444', desired_capabilities=None, browser_profile=None, proxy=None, keep_alive=True, file_detector=None, options: Optional[Union[selenium.webdriver.common.options.BaseOptions, List[selenium.webdriver.common.options.BaseOptions]]] = None)
Bases:
selenium.webdriver.remote.webdriver.WebDriver
,appium.webdriver.extensions.search_context.android.AndroidSearchContext
,appium.webdriver.extensions.search_context.custom.CustomSearchContext
,appium.webdriver.extensions.search_context.ios.iOSSearchContext
,appium.webdriver.extensions.search_context.mobile.MobileSearchContext
,appium.webdriver.extensions.search_context.windows.WindowsSearchContext
Returns appium driver search conext
- class AppiumWebElementSearchContext(parent, id_)
Bases:
selenium.webdriver.remote.webelement.WebElement
,appium.webdriver.extensions.search_context.android.AndroidSearchContext
,appium.webdriver.extensions.search_context.custom.CustomSearchContext
,appium.webdriver.extensions.search_context.ios.iOSSearchContext
,appium.webdriver.extensions.search_context.mobile.MobileSearchContext
,appium.webdriver.extensions.search_context.windows.WindowsSearchContext
Returns appium web element search context