From b8ad4566fa5aee7c94014073ffd4cfbfd0f91f17 Mon Sep 17 00:00:00 2001 From: Kyle McGonagle Date: Tue, 25 Jun 2019 22:34:47 -0400 Subject: [PATCH] Added EventFiringWebDriver to type check in pointer_input.py and tests for pointer and key input with EventFiringWebDriver. Fixes #6604 --- .../webdriver/common/actions/pointer_input.py | 3 +- .../support/event_firing_webdriver_tests.py | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/py/selenium/webdriver/common/actions/pointer_input.py b/py/selenium/webdriver/common/actions/pointer_input.py index 85916fabb9773..2216a5a2102c2 100644 --- a/py/selenium/webdriver/common/actions/pointer_input.py +++ b/py/selenium/webdriver/common/actions/pointer_input.py @@ -19,6 +19,7 @@ from selenium.common.exceptions import InvalidArgumentException from selenium.webdriver.remote.webelement import WebElement +from selenium.webdriver.support.event_firing_webdriver import EventFiringWebElement class PointerInput(InputDevice): @@ -37,7 +38,7 @@ def create_pointer_move(self, duration=DEFAULT_MOVE_DURATION, x=None, y=None, or action = dict(type="pointerMove", duration=duration) action["x"] = x action["y"] = y - if isinstance(origin, WebElement): + if isinstance(origin, (WebElement, EventFiringWebElement)): action["origin"] = {"element-6066-11e4-a52e-4f735466cecf": origin.id} elif origin is not None: action["origin"] = origin diff --git a/py/test/selenium/webdriver/support/event_firing_webdriver_tests.py b/py/test/selenium/webdriver/support/event_firing_webdriver_tests.py index 1246d964b1bc1..9a46aa877b59c 100644 --- a/py/test/selenium/webdriver/support/event_firing_webdriver_tests.py +++ b/py/test/selenium/webdriver/support/event_firing_webdriver_tests.py @@ -26,6 +26,7 @@ from selenium.webdriver.common.by import By from selenium.webdriver.support.events import EventFiringWebDriver, AbstractEventListener from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.common.actions.action_builder import ActionBuilder @pytest.fixture @@ -216,3 +217,30 @@ def test_missing_attributes_raise_error(driver, pages): with pytest.raises(AttributeError): element.attribute_should_not_exist + + +def test_can_use_pointer_input_with_event_firing_webdriver(driver, pages): + ef_driver = EventFiringWebDriver(driver, AbstractEventListener()) + pages.load("javascriptPage.html") + to_click = ef_driver.find_element_by_id("clickField") + + actions = ActionBuilder(ef_driver) + pointer = actions.pointer_action + pointer.move_to(to_click).click() + actions.perform() + + assert to_click.get_attribute('value') == 'Clicked' + + +def test_can_use_key_input_with_event_firing_webdriver(driver, pages): + ef_driver = EventFiringWebDriver(driver, AbstractEventListener()) + pages.load("javascriptPage.html") + keyUp = ef_driver.find_element_by_id("keyUp").click() + + actions = ActionBuilder(ef_driver) + key = actions.key_action + key.send_keys('Success') + actions.perform() + + result = ef_driver.find_element_by_id("result") + assert result.text == 'Success' \ No newline at end of file