Skip to content

Commit 3cf2eda

Browse files
committed
Add an example test that has switching to a new tab/window
1 parent ca0c064 commit 3cf2eda

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

examples/test_window_switching.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
Sometimes tests open new tabs/windows, and you'll need
3+
to switch to them first in order to interact with them.
4+
The starting window is window(0). Then increments by 1.
5+
"""
6+
from seleniumbase import BaseCase
7+
8+
9+
class TabSwitchingTests(BaseCase):
10+
11+
def test_switch_to_tabs(self):
12+
self.open("data:text/html,<h1>Page A</h1>")
13+
self.assert_text("Page A")
14+
self.open_new_window()
15+
self.open("data:text/html,<h1>Page B</h1>")
16+
self.assert_text("Page B")
17+
self.switch_to_window(0)
18+
self.assert_text("Page A")
19+
self.assert_text_not_visible("Page B")
20+
self.switch_to_window(1)
21+
self.assert_text("Page B")
22+
self.assert_text_not_visible("Page A")

0 commit comments

Comments
 (0)