There are scenarios where you might need to interact with multiple browser tabs in a test.
Any modern testing tool should support testing in multiple browser tabs.
And Endtest is no exception.
Interact with an element that is in a different browser tab
When a new browser tab gets opened, the test will not switch the focus automatically.
Since the element is in a separate browser tab, we have to tell the test to switch the focus to that browser tab before interacting with an element.
Miscellaneous action, you have the following methods:
Switch to next tab
Switch to previous tab
Switch to next tab method will be used when we need to switch focus to the next tab.
When we are done interacting with the elements from that browser tab, we can use the
Switch to previous tab method to switch the focus back to the original browser tab.
Opening a new tab
You may encounter scenarios where you need to open a new browser tab.
For example, in a Sign Up test, you might need to fetch the activation code from the Endtest Mailbox in a different browser tab.
You can use the
Open new tab method from the
When using that action, the test will automatically switch focus to the new tab.
That's why you need to add a
Switch to next tab step after that.
Closing a tab
Normally, you don't have to close browser tabs in a test.
The browser tabs get closed automatically when the test execution is finished.
But if you have a scenario where you need to do that, you can use the
Close tab method from the
When using that action, the test will automatically switch focus to the previous tab.
Switch to next taband
Switch to previous tabactions are using the
switch_to_windowmethod from Selenium WebDriver.
You should never remove the
target="_blank"attribute from link elements during your test.
That is a bad practice, since it modifies the web application that's being tested.
We strongly advise against using that method.