|
| 1 | +#!/usr/bin/env python |
| 2 | + |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +from selenium.webdriver.common.by import By |
| 16 | +from selenium.webdriver.remote.webelement import WebElement as SeleniumWebElement |
| 17 | + |
| 18 | +class WebElement(SeleniumWebElement): |
| 19 | + def find_element_by_ios_uiautomation(self, uia_string): |
| 20 | + """Finds an element by uiautomation in iOS. |
| 21 | +
|
| 22 | + :Args: |
| 23 | + - uia_string - The element name in the iOS UIAutomation library |
| 24 | +
|
| 25 | + :Usage: |
| 26 | + driver.find_element_by_ios_uiautomation('.elements()[1].cells()[2]') |
| 27 | + """ |
| 28 | + return self.find_element(by=By.IOS_UIAUTOMATION, value=uia_string) |
| 29 | + |
| 30 | + def find_elements_by_ios_uiautomation(self, uia_string): |
| 31 | + """Finds elements by uiautomation in iOS. |
| 32 | +
|
| 33 | + :Args: |
| 34 | + - uia_string - The element name in the iOS UIAutomation library |
| 35 | +
|
| 36 | + :Usage: |
| 37 | + driver.find_elements_by_ios_uiautomation('.elements()[1].cells()[2]') |
| 38 | + """ |
| 39 | + return self.find_elements(by=By.IOS_UIAUTOMATION, value=uia_string) |
| 40 | + |
| 41 | + def find_element_by_android_uiautomator(self, uia_string): |
| 42 | + """Finds element by uiautomator in Android. |
| 43 | +
|
| 44 | + :Args: |
| 45 | + - uia_string - The element name in the Android UIAutomator library |
| 46 | +
|
| 47 | + :Usage: |
| 48 | + driver.find_element_by_android_uiautomator('.elements()[1].cells()[2]') |
| 49 | + """ |
| 50 | + return self.find_element(by=By.ANDROID_UIAUTOMATOR, value=uia_string) |
| 51 | + |
| 52 | + def find_elements_by_android_uiautomator(self, uia_string): |
| 53 | + """Finds elements by uiautomator in Android. |
| 54 | +
|
| 55 | + :Args: |
| 56 | + - uia_string - The element name in the Android UIAutomator library |
| 57 | +
|
| 58 | + :Usage: |
| 59 | + driver.find_elements_by_android_uiautomator('.elements()[1].cells()[2]') |
| 60 | + """ |
| 61 | + return self.find_elements(by=By.ANDROID_UIAUTOMATOR, value=uia_string) |
| 62 | + |
| 63 | + def find_element_by_accessibility_id(self, id): |
| 64 | + """Finds an element by accessibility id. |
| 65 | +
|
| 66 | + :Args: |
| 67 | + - id - a string corresponding to a recursive element search using the |
| 68 | + Id/Name that the native Accessibility options utilize |
| 69 | +
|
| 70 | + :Usage: |
| 71 | + driver.find_element_by_accessibility_id() |
| 72 | + """ |
| 73 | + return self.find_element(by=By.ACCESSIBILITY_ID, value=id) |
| 74 | + |
| 75 | + def find_elements_by_accessibility_id(self, id): |
| 76 | + """Finds elements by accessibility id. |
| 77 | +
|
| 78 | + :Args: |
| 79 | + - id - a string corresponding to a recursive element search using the |
| 80 | + Id/Name that the native Accessibility options utilize |
| 81 | +
|
| 82 | + :Usage: |
| 83 | + driver.find_elements_by_accessibility_id() |
| 84 | + """ |
| 85 | + return self.find_elements(by=By.ACCESSIBILITY_ID, value=id) |
0 commit comments