Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wdspec] change test_..._closes_browsing_context #49765

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
9 changes: 8 additions & 1 deletion webdriver/tests/classic/perform_actions/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@ def test_no_browsing_context(session, closed_frame, key_chain):
def test_key_down_closes_browsing_context(
session, configuration, http_new_tab, inline, key_chain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that a window gets opened by the script we do no longer need the http_new_tab fixture here and in all the other tests.

Suggested change
session, configuration, http_new_tab, inline, key_chain
session, configuration, inline, key_chain

):
session.url = inline("""
url = inline("""
<input onkeydown="window.close()">close</input>
<script>document.querySelector("input").focus();</script>
""")

# Open a new window.
new_window = session.execute_script(f"return window.open('{url}')")

# Switch to the new window.
session.window_handle = new_window.id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still failing Firefox tests because none of the tests are waiting for the navigation to be completed. We need to wait for the input element to have the focus before we can start performing the action.


with pytest.raises(NoSuchWindowException):
key_chain.key_down("w") \
.pause(100 * configuration["timeout_multiplier"]) \
Expand Down
11 changes: 9 additions & 2 deletions webdriver/tests/classic/perform_actions/pointer_mouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,15 @@ def test_no_browsing_context(session, closed_frame, mouse_chain):
def test_pointer_down_closes_browsing_context(
session, configuration, http_new_tab, inline, mouse_chain
):
session.url = inline(
"""<input onpointerdown="window.close()">close</input>""")
url = inline("""<input onpointerdown="window.close()">close</input>""")

# Open a new window.
new_window = session.execute_script(f"return window.open('{url}')")

# Switch to the new window.
session.window_handle = new_window.id

# Get the input element.
origin = session.find.css("input", all=False)

with pytest.raises(NoSuchWindowException):
Expand Down
11 changes: 9 additions & 2 deletions webdriver/tests/classic/perform_actions/pointer_pen.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@ def test_no_browsing_context(session, closed_frame, pen_chain):
def test_pointer_down_closes_browsing_context(
session, configuration, http_new_tab, inline, pen_chain
):
session.url = inline(
"""<input onpointerdown="window.close()">close</input>""")
url = inline("""<input onpointerdown="window.close()">close</input>""")

# Open a new window.
new_window = session.execute_script(f"return window.open('{url}')")

# Switch to the new window.
session.window_handle = new_window.id

# Get the input element.
origin = session.find.css("input", all=False)

with pytest.raises(NoSuchWindowException):
Expand Down
11 changes: 9 additions & 2 deletions webdriver/tests/classic/perform_actions/pointer_touch.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,15 @@ def test_no_browsing_context(session, closed_frame, touch_chain):
def test_pointer_down_closes_browsing_context(
session, configuration, http_new_tab, inline, touch_chain
):
session.url = inline(
"""<input onpointerdown="window.close()">close</input>""")
url = inline("""<input onpointerdown="window.close()">close</input>""")

# Open a new window.
new_window = session.execute_script(f"return window.open('{url}')")

# Switch to the new window.
session.window_handle = new_window.id

# Get the input element.
origin = session.find.css("input", all=False)

with pytest.raises(NoSuchWindowException):
Expand Down
Loading