Riadayal / Pytest-multiple-tabs

A sample repo to help you handle multiple tabs in automation test in Pytest on LambdaTest. Run your automation test in Pytest on LambdaTest.

Home Page:https://www.lambdatest.com/pytest-testing/?utm_source=github&utm_medium=about&utm_campaign=Pytest_multiple_tabs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to handle multiple tabs in automation test in Pytest on LambdaTest

If you want to handle multiple tabs using an automation test in Pytest on LambdaTest, you can use the follwing steps. You can refer to sample test repo here.

Code

To open a new tab, you can use the following line of code:

driver.execute_script("window.open('about:blank','secondtab');")

To switch to the new tab, you can use the following line of code:

#by using tab name
driver.switch_to.window("secondtab")

or

#by using tab id
driver.switch_to.window("2")

For full code, refer to tabs.py.

Run your test

python tabs.py

Links:

LambdaTest Community