Skip to content

Add methods for handling tabs in CDP Mode #3579

Closed
@mdmintz

Description

@mdmintz

Add methods for handling tabs in CDP Mode

Up until now, CDP Mode hasn't had direct methods for simplifying the control of browser tabs. That's about to change. (One workaround has been to reconnect() to regular WebDriver to handle situations where tab-control is needed. Another workaround has been to call the async API indirectly.)

The following methods will be added to CDP Mode:

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()

To prevent confusion, the following methods will also be added as duplicates (because the regular SB naming scheme uses those):

sb.cdp.switch_to_window(window)
sb.cdp.switch_to_newest_window()

Note that 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().

Once implemented, it'll be easy to switch tabs if a website opens a new tab after an action is performed.

Metadata

Metadata

Assignees

Labels

UC Mode / CDP ModeUndetected Chromedriver Mode / CDP ModeenhancementMaking things better

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions