Skip to content
Open
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
11 changes: 0 additions & 11 deletions appium/webdriver/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,17 +474,6 @@ def _add_commands(self) -> None:
get_atter(self)

self.command_executor.add_command(Command.GET_STATUS, 'GET', '/status')

# TODO Move commands for element to webelement
self.command_executor.add_command(Command.CLEAR, 'POST', '/session/$sessionId/element/$id/clear')
self.command_executor.add_command(
Command.LOCATION_IN_VIEW,
'GET',
'/session/$sessionId/element/$id/location_in_view',
)

# MJSONWP for Selenium v4
self.command_executor.add_command(Command.IS_ELEMENT_DISPLAYED, 'GET', '/session/$sessionId/element/$id/displayed')
self.command_executor.add_command(Command.GET_CAPABILITIES, 'GET', '/session/$sessionId')

self.command_executor.add_command(Command.GET_SCREEN_ORIENTATION, 'GET', '/session/$sessionId/orientation')
Expand Down
18 changes: 18 additions & 0 deletions appium/webdriver/webelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from selenium.webdriver.common.utils import keys_to_typing
from selenium.webdriver.remote.command import Command as RemoteCommand
from selenium.webdriver.remote.webdriver import WebDriver as Remote
from selenium.webdriver.remote.webelement import WebElement as SeleniumWebElement
from typing_extensions import Self

Expand All @@ -35,6 +36,23 @@ def find_element(self, by: str, value: str | dict | None = None) -> Self: # typ
def find_elements(self, by: str, value: str | dict | None = None) -> list[Self]: # type: ignore[override]
...

def __init__(self, parent: Remote, id_: int | str) -> None:
super().__init__(parent, id_) # type: ignore[arg-type]
self._add_commands()

def _add_commands(self) -> None:
self._parent.command_executor.add_command(Command.CLEAR, 'POST', '/session/$sessionId/element/$id/clear')
self._parent.command_executor.add_command(
Command.LOCATION_IN_VIEW,
'GET',
'/session/$sessionId/element/$id/location_in_view',
)
self._parent.command_executor.add_command(
Command.IS_ELEMENT_DISPLAYED,
'GET',
'/session/$sessionId/element/$id/displayed',
)

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

Expand Down
12 changes: 12 additions & 0 deletions test/unit/webdriver/webelement_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,15 @@ def test_element_location_in_view(self):
httpretty.last_request()

assert loc == location_in_view

@httpretty.activate
def test_is_displayed(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.GET,
appium_command('/session/1234567890/element/element_id/displayed'),
body=json.dumps({'value': True}),
)

element = MobileWebElement(driver, 'element_id')
assert element.is_displayed() is True
Loading