Skip to content

Commit ab6c7bb

Browse files
authored
chore: wrong usage of CanFindElements #1148 (#1152)
* chore: revert protocol * add doc
1 parent abf210a commit ab6c7bb

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

appium/options/common/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def __init__(self) -> None:
6969
# FIXME: https://github.com/SeleniumHQ/selenium/issues/10755
7070
self._ignore_local_proxy = False
7171

72-
def set_capability(self: T, name: str, value: Any) -> T:
72+
def set_capability(self: T, name: str, value: Any) -> T: # type: ignore[override]
7373
w3c_name = name if name in self.W3C_CAPABILITY_NAMES or ':' in name else f'{APPIUM_PREFIX}{name}'
7474
if value is None:
7575
if w3c_name in self._caps:

appium/protocols/webdriver/can_find_elements.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,21 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from typing import TYPE_CHECKING, Dict, List, Protocol, Union
15+
from typing import TYPE_CHECKING, Dict, List, Protocol, Union, runtime_checkable
1616

1717
if TYPE_CHECKING:
1818
from appium.webdriver.webelement import WebElement
1919

2020

21+
@runtime_checkable
2122
class CanFindElements(Protocol):
23+
"""Protocol for objects that can find web elements.
24+
25+
Any class implementing this protocol must provide:
26+
- find_element(by, value): Find a single element
27+
- find_elements(by, value): Find multiple elements
28+
"""
29+
2230
def find_element(self, by: str, value: Union[str, Dict, None] = None) -> 'WebElement': ...
2331

2432
def find_elements(self, by: str, value: Union[str, Dict, None] = None) -> List['WebElement']: ...

appium/webdriver/webdriver.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
from appium.common.logger import logger
3030
from appium.options.common.base import AppiumOptions
31-
from appium.protocols.webdriver.can_find_elements import CanFindElements
3231
from appium.webdriver.common.appiumby import AppiumBy
3332

3433
from .appium_connection import AppiumConnection
@@ -238,7 +237,6 @@ class WebDriver(
238237
Settings,
239238
Sms,
240239
SystemBars,
241-
CanFindElements,
242240
):
243241
def __init__(
244242
self,

appium/webdriver/webelement.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@
1919
from selenium.webdriver.remote.webelement import WebElement as SeleniumWebElement
2020
from typing_extensions import Self
2121

22-
from appium.protocols.webdriver.can_find_elements import CanFindElements
23-
2422
from .mobilecommand import MobileCommand as Command
2523

2624

27-
class WebElement(SeleniumWebElement, CanFindElements):
25+
class WebElement(SeleniumWebElement):
2826
_execute: Callable
2927
_id: str
3028

31-
def get_attribute(self, name: str) -> Optional[Union[str, Dict]]:
29+
def get_attribute(self, name: str) -> Optional[Union[str, Dict]]: # type: ignore[override]
3230
"""Gets the given attribute or property of the element.
3331
3432
Override for Appium
@@ -80,7 +78,7 @@ def is_displayed(self) -> bool:
8078
"""
8179
return self._execute(Command.IS_ELEMENT_DISPLAYED)['value']
8280

83-
def clear(self) -> Self:
81+
def clear(self) -> Self: # type: ignore[override]
8482
"""Clears text.
8583
8684
Override for Appium

0 commit comments

Comments
 (0)