How do i switch tabs or windows?
Is there a way to detect tabs or windows and switch to it?
You can write custom helpers for now. Below is e.g. for WebDriverIO
/**
waitTabsLoading(ammountOfTabs, timeout) {
timeout = timeout || 15;
let client = this.helpers['Appium'].browser;
return client
.waitUntil(function () {
return this.getTabIds().then(function (handles) {
return handles.length === ammountOfTabs
});
}, timeout * 1000, "The number of tabs hasn't changed to " + ammountOfTabs);
}
changeTab(num) {
let client = this.helpers['Appium'].browser;
return client
.getTabIds().then(function (handles) {
return this.switchTab(handles[num - 1]);
});
}
I'll add them to basic metods for WebdriverIO
https://github.com/Codeception/CodeceptJS/pull/606
@APshenkin - You said this example was for for webdriverio, but the code it using Appium. When I change your code to use webdriverio, I get this error: "Error: Session ID is null. Using WebDriver after calling quit()?"
@patmeeker there is default methods in codeceptjs for this now. Please update codeceptJS to 1.0.2 and check documentation: http://codecept.io/helpers/WebDriverIO/#switchtonexttab
Got it! Thanks!
Dead link: check documentation: http://codecept.io/helpers/WebDriverIO/#switchtonexttab