简体   繁体   中英

Python Selenium with Chrome. How to switch between different tabs

I click a button which opens a new tab. How to I then navigate around the new tab?

This sounds like a simple task but after several hours trying to find a solution I'm not any closer. Is there a simple way of doing this?

Tried using keys for CONTROL + 'T' and read other suggestions but nothing seems to work.

Many thanks

I just implemented my solution and it worked for my case, which looks very similar to yours.

First you need to check the window_handles :

len(driver.window_handles) > 1

If you have more than one, you can try to switch to your second handler:

driver.switch_to_window(driver.window_handles[1])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM