Endtest

Endtest

›Web Tests

Web Tests

  • How to create Web Tests
  • Finding elements in Web Applications
  • How to execute Web Tests
  • Assertions for Web Tests
  • IF Statements for Web Tests
  • Web Applications with restricted access
  • How to test in iframes
  • How to test in multiple tabs
  • How to test File Uploads
  • How to test File Downloads
  • How to test Emails
  • How to test PDF files
  • How to test Chrome Extensions
  • Dealing with reCAPTCHA
  • Dealing with Dynamic Locators
  • Dealing with Canvas Elements
  • Performing a Drag and Drop
  • Execute JavaScript
  • Testing WebRTC Applications
  • How to scroll in Web Tests
  • How to test Checkboxes
  • How to test Dropdowns
  • Dealing with Sessions
  • Web Crawler
  • Export Web Tests
  • Migrating from Selenium

Mobile Tests

  • How to create Mobile Tests
  • Finding elements in Mobile Applications
  • How to execute Mobile Tests
  • Assertions for Mobile Tests
  • IF Statements for Mobile Tests
  • How to scroll in Mobile Tests
  • Performing Complex Gestures

Advanced

  • Variables
  • Waits
  • Endtest API
  • Scheduler
  • Drive
  • Adding Collaborators
  • Computer Vision
  • Importing Test Cases
  • Using Loops
  • Data-driven Testing
  • Send API Requests
  • Read SMS
  • Execute SQL queries
  • Self-Healing Tests
  • Email Notifications
  • Slack Notifications
  • PagerDuty Notifications
  • Webhook Notifications
  • Automatic Backup
  • Advanced Settings
  • Multiple environments
  • How to stop a test
  • Utilities
  • Utilities API
  • Team
  • On-Premises

Integrations

  • Atlassian Jira
  • Slack
  • PagerDuty
  • Microsoft Teams
  • Mattermost
  • Jenkins
  • GitHub
  • Azure DevOps
  • GitLab
  • TeamCity
  • CircleCI
  • TravisCI
  • Bitbucket
  • Heroku
  • Bamboo Server
  • Test Case Management
  • SSO
  • BrowserStack
  • Sauce Labs

How to test in multiple tabs

Introduction

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.

In the Miscellaneous action, you have the following methods:

  • Switch to next tab
  • Switch to previous tab

The 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.

As of February 2025, the logic for switching browser tabs has been enhanced.

Please be aware that some existing tests may rely on workarounds that function only with the previous method. To manage these situations, we have introduced the Switch Browser Tabs setting in the Advanced Settings section of Web Tests:

  • Standard: Utilizes the updated switching logic.
  • Legacy: Continues to employ the former logic.

The Legacy option is slated for deprecation. We recommend using the Standard option for future-proofing your tests.

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 Miscellaneous action.

When using that action, the test will automatically switch focus to the new tab.

Or you can add an Execute JavaScript step, with the following JavaScript code:

window.open('');

And you can even provide the URL directly in the JavaScript code:

window.open('https://app.endtest.io/mailbox?email={{$email}}');

When using JavaScript to open a new tab, the test will not automatically switch focus to that 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 Miscellaneous action.

When using that action, the test will automatically switch focus to the previous tab.


The Switch to next tab and Switch to previous tab actions are using the switch_to_window method 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.

← How to test in iframesHow to test File Uploads →
  • Introduction
  • Interact with an element that is in a different browser tab
  • Opening a new tab
  • Closing a tab
© Endtest Inc.