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

How to close a window with no tab? #3794

Eduardo-Qinttus started this conversation in General
Discussion options

window_ = window
while window_ == window:
sb.cdp.switch_to_newest_window()
window_ = sb.cdp.get_window()
sleep(2)
sb.cdp.switch_to_window(window_)
sleep(1)
sb.cdp.close_active_tab()

the window_ is a about:blank opened with java script.

the error:
tab must be an int or a Tab type!

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

These are the available CDP Mode methods for handling tabs:

sb.cdp.switch_to_tab(tab)
sb.cdp.switch_to_newest_tab()
sb.cdp.close_active_tab()
sb.cdp.get_active_tab()
sb.cdp.get_tabs()

With sb.cdp.switch_to_tab(tab), tab can be either an integer representing the list location from sb.cdp.get_tabs(), or it can be the actual Tab object from the list. If the tab you wish to switch to is the newest opened tab, you can just call sb.cdp.switch_to_newest_tab().

Note that you can only control tabs that appear in sb.cdp.get_tabs(). If it's not there, then you'll need to call sb.reconnect() and try to use regular Selenium methods for it.

You must be logged in to vote
1 reply
Comment options

Ok, i will try with sb.reconnect. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

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