switchTo()
Allows switching between tabs and windows using URL or page title or Window name.
Examples
Section titled “Examples”# Switch using URLawait switchTo(/taiko.dev/)# Switch using Titleawait switchTo(/Taiko/)# Switch using Regex URLawait switchTo(/http(s?):\/\/(www?).google.(com|co.in|co.uk)/)# Switch using wild cards in the Regexawait switchTo(/Go*gle/)# Switch to a window identifierawait openBrowser();await goto('google.com');openIncognitoWindow({ name: "newyorktimes"});switchTo(/google.com/);switchTo({ name: "newyorktimes"});openTab('https://taiko.dev', {name: 'taiko'})openIncognitoWindow({ name: "newyorktimes"});switchTo({name: 'taiko'});Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
arg | string | Regex (Regular expression) the tab’s title/URL or Object withwindow name for example { name: "windowname"} |
Returns
Section titled “Returns”| Type | Description |
|---|---|
Promise<void> |