-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
How to close a window with no tab? #3794
-
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!
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 1 reply
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
Ok, i will try with sb.reconnect. Thanks!
Beta Was this translation helpful? Give feedback.