|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -from typing import Callable, Dict, List, Optional, Union |
| 15 | +from typing import Callable, Dict, Optional, Union |
16 | 16 |
|
17 | 17 | from selenium.webdriver.common.utils import keys_to_typing |
18 | 18 | from selenium.webdriver.remote.command import Command as RemoteCommand |
19 | 19 | from selenium.webdriver.remote.webelement import WebElement as SeleniumWebElement |
20 | 20 | from typing_extensions import Self |
21 | 21 |
|
22 | | -from appium.webdriver.common.appiumby import AppiumBy |
23 | | - |
24 | 22 | from .mobilecommand import MobileCommand as Command |
25 | 23 |
|
26 | 24 |
|
@@ -80,69 +78,69 @@ def is_displayed(self) -> bool: |
80 | 78 | """ |
81 | 79 | return self._execute(Command.IS_ELEMENT_DISPLAYED)['value'] |
82 | 80 |
|
83 | | - def find_element(self, by: str = AppiumBy.ID, value: Union[str, Dict, None] = None) -> 'WebElement': |
84 | | - """Find an element given a AppiumBy strategy and locator |
85 | | -
|
86 | | - Override for Appium |
87 | | -
|
88 | | - Prefer the find_element_by_* methods when possible. |
89 | | -
|
90 | | - Args: |
91 | | - by: The strategy |
92 | | - value: The locator |
93 | | -
|
94 | | - Usage: |
95 | | - element = element.find_element(AppiumBy.ID, 'foo') |
96 | | -
|
97 | | - Returns: |
98 | | - `appium.webdriver.webelement.WebElement` |
99 | | - """ |
100 | | - # We prefer to patch locators in the client code |
101 | | - # Checking current context every time a locator is accessed could significantly slow down tests |
102 | | - # Check https://github.com/appium/python-client/pull/724 before submitting any issue |
103 | | - # if by == By.ID: |
104 | | - # by = By.CSS_SELECTOR |
105 | | - # value = '[id="%s"]' % value |
106 | | - # elif by == By.TAG_NAME: |
107 | | - # by = By.CSS_SELECTOR |
108 | | - # elif by == By.CLASS_NAME: |
109 | | - # by = By.CSS_SELECTOR |
110 | | - # value = ".%s" % value |
111 | | - # elif by == By.NAME: |
112 | | - # by = By.CSS_SELECTOR |
113 | | - # value = '[name="%s"]' % value |
114 | | - |
115 | | - return self._execute(RemoteCommand.FIND_CHILD_ELEMENT, {'using': by, 'value': value})['value'] |
116 | | - |
117 | | - def find_elements(self, by: str = AppiumBy.ID, value: Union[str, Dict, None] = None) -> List['WebElement']: |
118 | | - """Find elements given a AppiumBy strategy and locator |
119 | | -
|
120 | | - Args: |
121 | | - by: The strategy |
122 | | - value: The locator |
123 | | -
|
124 | | - Usage: |
125 | | - element = element.find_elements(AppiumBy.CLASS_NAME, 'foo') |
126 | | -
|
127 | | - Returns: |
128 | | - :obj:`list` of :obj:`appium.webdriver.webelement.WebElement` |
129 | | - """ |
130 | | - # We prefer to patch locators in the client code |
131 | | - # Checking current context every time a locator is accessed could significantly slow down tests |
132 | | - # Check https://github.com/appium/python-client/pull/724 before submitting any issue |
133 | | - # if by == By.ID: |
134 | | - # by = By.CSS_SELECTOR |
135 | | - # value = '[id="%s"]' % value |
136 | | - # elif by == By.TAG_NAME: |
137 | | - # by = By.CSS_SELECTOR |
138 | | - # elif by == By.CLASS_NAME: |
139 | | - # by = By.CSS_SELECTOR |
140 | | - # value = ".%s" % value |
141 | | - # elif by == By.NAME: |
142 | | - # by = By.CSS_SELECTOR |
143 | | - # value = '[name="%s"]' % value |
144 | | - |
145 | | - return self._execute(RemoteCommand.FIND_CHILD_ELEMENTS, {'using': by, 'value': value})['value'] |
| 81 | + # def find_element(self, by: str = AppiumBy.ID, value: Union[str, Dict, None] = None) -> 'WebElement': |
| 82 | + # """Find an element given a AppiumBy strategy and locator |
| 83 | + |
| 84 | + # Override for Appium |
| 85 | + |
| 86 | + # Prefer the find_element_by_* methods when possible. |
| 87 | + |
| 88 | + # Args: |
| 89 | + # by: The strategy |
| 90 | + # value: The locator |
| 91 | + |
| 92 | + # Usage: |
| 93 | + # element = element.find_element(AppiumBy.ID, 'foo') |
| 94 | + |
| 95 | + # Returns: |
| 96 | + # `appium.webdriver.webelement.WebElement` |
| 97 | + # """ |
| 98 | + # # We prefer to patch locators in the client code |
| 99 | + # # Checking current context every time a locator is accessed could significantly slow down tests |
| 100 | + # # Check https://github.com/appium/python-client/pull/724 before submitting any issue |
| 101 | + # # if by == By.ID: |
| 102 | + # # by = By.CSS_SELECTOR |
| 103 | + # # value = '[id="%s"]' % value |
| 104 | + # # elif by == By.TAG_NAME: |
| 105 | + # # by = By.CSS_SELECTOR |
| 106 | + # # elif by == By.CLASS_NAME: |
| 107 | + # # by = By.CSS_SELECTOR |
| 108 | + # # value = ".%s" % value |
| 109 | + # # elif by == By.NAME: |
| 110 | + # # by = By.CSS_SELECTOR |
| 111 | + # # value = '[name="%s"]' % value |
| 112 | + |
| 113 | + # return self._execute(RemoteCommand.FIND_CHILD_ELEMENT, {'using': by, 'value': value})['value'] |
| 114 | + |
| 115 | + # def find_elements(self, by: str = AppiumBy.ID, value: Union[str, Dict, None] = None) -> List['WebElement']: |
| 116 | + # """Find elements given a AppiumBy strategy and locator |
| 117 | + |
| 118 | + # Args: |
| 119 | + # by: The strategy |
| 120 | + # value: The locator |
| 121 | + |
| 122 | + # Usage: |
| 123 | + # element = element.find_elements(AppiumBy.CLASS_NAME, 'foo') |
| 124 | + |
| 125 | + # Returns: |
| 126 | + # :obj:`list` of :obj:`appium.webdriver.webelement.WebElement` |
| 127 | + # """ |
| 128 | + # # We prefer to patch locators in the client code |
| 129 | + # # Checking current context every time a locator is accessed could significantly slow down tests |
| 130 | + # # Check https://github.com/appium/python-client/pull/724 before submitting any issue |
| 131 | + # # if by == By.ID: |
| 132 | + # # by = By.CSS_SELECTOR |
| 133 | + # # value = '[id="%s"]' % value |
| 134 | + # # elif by == By.TAG_NAME: |
| 135 | + # # by = By.CSS_SELECTOR |
| 136 | + # # elif by == By.CLASS_NAME: |
| 137 | + # # by = By.CSS_SELECTOR |
| 138 | + # # value = ".%s" % value |
| 139 | + # # elif by == By.NAME: |
| 140 | + # # by = By.CSS_SELECTOR |
| 141 | + # # value = '[name="%s"]' % value |
| 142 | + |
| 143 | + # return self._execute(RemoteCommand.FIND_CHILD_ELEMENTS, {'using': by, 'value': value})['value'] |
146 | 144 |
|
147 | 145 | def clear(self) -> Self: |
148 | 146 | """Clears text. |
|
0 commit comments