Skip to content

chore: wrong usage of CanFindElements #1148 #1152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 2, 2025
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
2 changes: 1 addition & 1 deletion appium/options/common/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(self) -> None:
# FIXME: https://github.com/SeleniumHQ/selenium/issues/10755
self._ignore_local_proxy = False

def set_capability(self: T, name: str, value: Any) -> T:
def set_capability(self: T, name: str, value: Any) -> T: # type: ignore[override]
w3c_name = name if name in self.W3C_CAPABILITY_NAMES or ':' in name else f'{APPIUM_PREFIX}{name}'
if value is None:
if w3c_name in self._caps:
Expand Down
10 changes: 9 additions & 1 deletion appium/protocols/webdriver/can_find_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import TYPE_CHECKING, Dict, List, Protocol, Union
from typing import TYPE_CHECKING, Dict, List, Protocol, Union, runtime_checkable

if TYPE_CHECKING:
from appium.webdriver.webelement import WebElement


@runtime_checkable
class CanFindElements(Protocol):
"""Protocol for objects that can find web elements.

Any class implementing this protocol must provide:
- find_element(by, value): Find a single element
- find_elements(by, value): Find multiple elements
"""

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

def find_elements(self, by: str, value: Union[str, Dict, None] = None) -> List['WebElement']: ...
2 changes: 0 additions & 2 deletions appium/webdriver/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

from appium.common.logger import logger
from appium.options.common.base import AppiumOptions
from appium.protocols.webdriver.can_find_elements import CanFindElements
from appium.webdriver.common.appiumby import AppiumBy

from .appium_connection import AppiumConnection
Expand Down Expand Up @@ -238,7 +237,6 @@ class WebDriver(
Settings,
Sms,
SystemBars,
CanFindElements,
):
def __init__(
self,
Expand Down
8 changes: 3 additions & 5 deletions appium/webdriver/webelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@
from selenium.webdriver.remote.webelement import WebElement as SeleniumWebElement
from typing_extensions import Self

from appium.protocols.webdriver.can_find_elements import CanFindElements

from .mobilecommand import MobileCommand as Command


class WebElement(SeleniumWebElement, CanFindElements):
class WebElement(SeleniumWebElement):
_execute: Callable
_id: str

def get_attribute(self, name: str) -> Optional[Union[str, Dict]]:
def get_attribute(self, name: str) -> Optional[Union[str, Dict]]: # type: ignore[override]
"""Gets the given attribute or property of the element.

Override for Appium
Expand Down Expand Up @@ -80,7 +78,7 @@ def is_displayed(self) -> bool:
"""
return self._execute(Command.IS_ELEMENT_DISPLAYED)['value']

def clear(self) -> Self:
def clear(self) -> Self: # type: ignore[override]
"""Clears text.

Override for Appium
Expand Down