How can I handle multiple tabs in Selenium pytest?
Hi Miro!
To handle multiple tabs in Selenium pytest testing, you can follow the below steps -
- To open a new tab, you can use the below line of code:
driver.execute_script("window.open('about:blank','secondtab');")
- To switch to the new tab, you can use the below line of code:
#by using tab name
driver.switch_to.window("secondtab")
or
#by using tab id
driver.switch_to.window("2")
For more info, please refer to the below GitHub repo-