botasaurus icon indicating copy to clipboard operation
botasaurus copied to clipboard

How to manage browser tabs

Open sdv75 opened this issue 1 year ago • 1 comments

Example from Selenium get num tabs - driver.window_handles switch to tab - driver.switch_to.window(tab hash)

Please write how to do it in botasaurus?

sdv75 avatar Sep 03 '24 17:09 sdv75

I found it. See cdp target. driver.run_cdp_command(cdp.target.get_targets()) return quantity of tabs

sdv75 avatar Sep 05 '24 07:09 sdv75

Did you find any way to switch to a popup window ?

ItsWhoCares avatar Nov 11 '24 06:11 ItsWhoCares

Popup is an iframe or div block.

sdv75 avatar Nov 11 '24 08:11 sdv75

It is a seperate browser window, the one's you get when you click on a sign in button for Google or Microsoft account.

ItsWhoCares avatar Nov 11 '24 14:11 ItsWhoCares

I have found this solution for now driver.switch_to_tab(driver._browser.tabs[1])

sdv75 avatar Jan 07 '25 20:01 sdv75

For some reason - None of the solutions are working

Tried: driver.switch_to_tab(driver._browser.tabs[1])

Finally found working solutions First we can get list of tabs driver._browser.tabs[-1]

Next, to select that tab driver._tab = driver._browser.tabs[-1] This won't do anything on scene but It'll select in code context.

Next do any action of that tab Eg. close it driver._tab.close()

Parth971 avatar Jan 30 '25 16:01 Parth971

you can use methods like open_link_in_new_tab, switch_to_tab, to manage tab, also every get function like get, get_via_google returns a tab.

Chetan11-dev avatar Mar 06 '25 10:03 Chetan11-dev