Skip to content

Commit

Permalink
Added EventFiringWebDriver to type check in pointer_input.py and test…
Browse files Browse the repository at this point in the history
…s for pointer and key input with EventFiringWebDriver.

Fixes #6604
  • Loading branch information
Kyle McGonagle authored and AutomatedTester committed Jun 27, 2019
1 parent 3eeb405 commit b8ad456
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion py/selenium/webdriver/common/actions/pointer_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down
28 changes: 28 additions & 0 deletions py/test/selenium/webdriver/support/event_firing_webdriver_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'

0 comments on commit b8ad456

Please sign in to comment.