-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathtest_window_switching.py
More file actions
24 lines (22 loc) · 838 Bytes
/
test_window_switching.py
File metadata and controls
24 lines (22 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""
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
BaseCase.main(__name__, __file__)
class TabSwitchingTests(BaseCase):
def test_switch_to_tabs(self):
self.open("about:blank")
self.get_new_driver()
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")