Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,22 @@ els = self.driver.find_elements_by_android_uiautomator('new UiSelector().clickab
self.assertIsInstance(els, list)
```

### Finding elements by Android viewtag search

This method allows finiding elements using [View#tags](https://developer.android.com/reference/android/view/View#tags).
This method works with [Espresso Driver](https://github.com/appium/appium-espresso-driver).

Adds the methods `driver.find_element_by_android_viewtag` and `driver.find_elements_by_android_viewtag`.

```python
el = self.driver.find_element_by_android_viewtag('a tag name')
self.assertIsNotNone(el)
```

```python
els = self.driver.find_elements_by_android_viewtag('a tag name')
self.assertIsInstance(els, list)
```

### Finding elements by iOS predicates

Expand Down
1 change: 1 addition & 0 deletions appium/webdriver/common/mobileby.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ class MobileBy(By):
IOS_UIAUTOMATION = '-ios uiautomation'
IOS_CLASS_CHAIN = '-ios class chain'
ANDROID_UIAUTOMATOR = '-android uiautomator'
ANDROID_VIEWTAG = '-android viewtag'
ACCESSIBILITY_ID = 'accessibility id'
IMAGE = '-image'
24 changes: 24 additions & 0 deletions appium/webdriver/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,30 @@ def find_elements_by_android_uiautomator(self, uia_string):
"""
return self.find_elements(by=By.ANDROID_UIAUTOMATOR, value=uia_string)

def find_element_by_android_viewtag(self, tag):
"""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).

:Args:
- tag - The tag name of the view to look for

:Usage:
driver.find_element_by_android_viewtag('a tag name')
"""
return self.find_element(by=By.ANDROID_VIEWTAG, value=tag)

def find_elements_by_android_viewtag(self, tag):
"""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).

:Args:
- tag - The tag name of the view to look for

:Usage:
driver.find_elements_by_android_viewtag('a tag name')
"""
return self.find_elements(by=By.ANDROID_VIEWTAG, value=tag)

def find_element_by_image(self, png_img_path,
match_threshold=DEFAULT_MATCH_THRESHOLD):
"""Finds a portion of a screenshot by an image.
Expand Down