Skip to content

Commit

Permalink
Pure BiDi new_tab fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksim Sadym authored and sadym-chromium committed Jun 29, 2022
1 parent 70854d2 commit 1001664
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions webdriver/tests/support/fixtures_bidi.py
Expand Up @@ -6,20 +6,14 @@


@pytest.fixture
async def new_tab(bidi_session, current_session):
# Open and focus a new tab to run the test in a foreground tab.
context_id = current_session.new_window(type_hint="tab")
initial_window = current_session.window_handle
current_session.window_handle = context_id
async def new_tab(bidi_session):
new_tab = await bidi_session.browsing_context.create(type_hint='tab')

# Retrieve the browsing context info for the new tab
contexts = await bidi_session.browsing_context.get_tree(root=context_id, max_depth=0)
yield contexts[0]
yield new_tab

# Restore the focus and current window for the WebDriver session before
# closing the tab.
current_session.window_handle = initial_window
await bidi_session.browsing_context.close(context=contexts[0]["context"])
# Close the tab.
await bidi_session.browsing_context.close(context=new_tab)


@pytest.fixture
Expand Down

0 comments on commit 1001664

Please sign in to comment.