Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to manage browser tabs #182

Closed
sdv75 opened this issue Sep 3, 2024 · 7 comments
Closed

How to manage browser tabs #182

sdv75 opened this issue Sep 3, 2024 · 7 comments

Comments

@sdv75
Copy link

sdv75 commented Sep 3, 2024

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
Copy link
Author

sdv75 commented Sep 5, 2024

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

@ItsWhoCares
Copy link

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

@sdv75
Copy link
Author

sdv75 commented Nov 11, 2024

Popup is an iframe or div block.

@ItsWhoCares
Copy link

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

@sdv75
Copy link
Author

sdv75 commented Jan 7, 2025

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

@Parth971
Copy link

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

@Chetan11-dev
Copy link
Contributor

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.

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

No branches or pull requests

4 participants