Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Handling Multiple Window Tab #1068

Answered by mdmintz
abdurraheemj asked this question in Q&A
Discussion options

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

You must be logged in to vote

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

Comment options

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.

You must be logged in to vote
0 replies
Answer selected by mdmintz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /