Add an example test that has switching to a new tab/window

This commit is contained in:
Michael Mintz 2021-03-16 19:40:31 -04:00
parent ca0c064ff5
commit 3cf2eda808
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
"""
Sometimes tests open new tabs/windows, and you'll need
to switch to them first in order to interact with them.
The starting window is window(0). Then increments by 1.
"""
from seleniumbase import BaseCase
class TabSwitchingTests(BaseCase):
def test_switch_to_tabs(self):
self.open("data:text/html,<h1>Page A</h1>")
self.assert_text("Page A")
self.open_new_window()
self.open("data:text/html,<h1>Page B</h1>")
self.assert_text("Page B")
self.switch_to_window(0)
self.assert_text("Page A")
self.assert_text_not_visible("Page B")
self.switch_to_window(1)
self.assert_text("Page B")
self.assert_text_not_visible("Page A")