The Switch tab command allows you to switch to a different tab based on a substring, regular expression, or index match. Note that if the switching condition matches the current active tab, this command will immediately return.

This command automatically retries upon until the smart waiting timeout timeout if no matching tabs can be found. This allows tests to handle new tabs that may be opened after a delay in a graceful manner.

Inputs

matcher
string | number
required

A substring, regular expression, or index match for the tab to switch to.

For substrings and regular expressions, the matcher will be compared against the absolute URL of all tabs. Partial matches are counted as successful matches for regular expressions.

If the matcher matchs multiple tabs, the last match is taken.

Was this page helpful?