Skip to content
Open
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
25 changes: 25 additions & 0 deletions test/unit/webdriver/webdriver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import pytest
import urllib3
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.common.by import By

from appium import webdriver
from appium.options.android import UiAutomator2Options
Expand Down Expand Up @@ -294,6 +295,30 @@ def test_get_events_catches_missing_events(self):
events = driver.events
assert events == {}

@httpretty.activate
@pytest.mark.parametrize('by', [By.ID, By.NAME, By.CLASS_NAME])
def test_find_element_keeps_locator_strategy(self, by):
# Selenium's default LocatorConverter rewrites these strategies to 'css selector',
# which Appium native contexts do not support.
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/element'),
body='{"value": {"element-6066-11e4-a52e-4f735466cecf": "element-id"}}',
)
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/element/element-id/element'),
body='{"value": {"element-6066-11e4-a52e-4f735466cecf": "child-element-id"}}',
)
el = driver.find_element(by=by, value='foo')
d = get_httpretty_request_body(httpretty.last_request())
assert d == {'using': by, 'value': 'foo'}

el.find_element(by=by, value='bar')
d = get_httpretty_request_body(httpretty.last_request())
assert d == {'using': by, 'value': 'bar'}

@httpretty.activate
@patch('appium.webdriver.webdriver.logger.warning')
def test_session_catches_error(self, mock_warning):
Expand Down
Loading