.switchToWindow() Suggest edits
Change focus to another window. The window to change focus to may be specified by its server assigned window handle, or by the value of its name attribute.
To find out the window handle use windowHandles
command
Usage
Parameters
Name | Type | description |
---|---|---|
handleOrName |
string | The server assigned window handle or the name attribute. |
callback Optional |
function | Optional callback function to be called when the command finishes. |
Example
this.demoTest = function (browser) {
browser.windowHandles(function(result) {
var handle = result.value[0];
browser.switchToWindow(handle);
});
};
this.demoTestAsync = async function (browser) {
const result = await browser.windowHandles();
var handle = result.value[0];
browser.switchToWindow(handle);
};