from tests.support.asserts import assert_success
def element_click(session, element):
return session.transport.send(
"POST", "/session/{session_id}/element/{element_id}/click".format(
session_id=session.session_id,
element_id=element.id))
def test_click_event_bubbles_to_parents(session, inline):
session.url = inline("""
""")
three, two, one = session.find.css("div")
one.click()
clicks = session.execute_script("return window.clicks")
assert one in clicks
assert two in clicks
assert three in clicks
def test_spin_event_loop(session, inline):
"""
Wait until the user agent event loop has spun enough times to
process the DOM events generated by clicking.
"""
session.url = inline("""
""")
three, two, one = session.find.css("div")
one.click()
delayed_clicks = session.execute_script("return window.delayedClicks")
assert one in delayed_clicks
assert two in delayed_clicks
assert three in delayed_clicks
def test_element_disappears_during_click(session, inline):
"""
When an element in the event bubbling order disappears (its CSS
display style is set to "none") during a click, Gecko and Blink
exhibit different behaviour. Whilst Chrome fires a "click"
DOM event on , Firefox does not.
A WebDriver implementation may choose to wait for this event to let
the event loops spin enough times to let click events propagate,
so this is a corner case test that Firefox does not hang indefinitely.
"""
session.url = inline("""
""")
over = session.find.css("#over", all=False)
# should not time out
response = element_click(session, over)
assert_success(response)