-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Handling Multiple Window Tab #1068
-
Hi Michael,
working on a project which deals with multiple tabs,
Examples:
1.opening a URL
2. click on a link switch to new tab and get the header(to assert the text with step #3)
3. back to parent tab click on a ink, switch to new tab and get the header
4.going back to parent tab and repeat.
my problem is want to close those two tabs before going to step 4
Beta Was this translation helpful? Give feedback.
All reactions
Hi @abdurraheemj,
https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_window_switching.py has a good example of opening new tabs and switching between them. If you need to close a tab, use self.driver.close()
. Opening a new tab can be done with self.open_new_window()
, but you have to have at least one tab open to do that because it calls self.driver.execute_script("window.open('');")
to open the new tab, which requires an open tab to run that in the console.
Replies: 1 comment
-
Hi @abdurraheemj,
https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_window_switching.py has a good example of opening new tabs and switching between them. If you need to close a tab, use self.driver.close()
. Opening a new tab can be done with self.open_new_window()
, but you have to have at least one tab open to do that because it calls self.driver.execute_script("window.open('');")
to open the new tab, which requires an open tab to run that in the console.
Beta Was this translation helpful? Give feedback.