I am trying to run Webdriver + Mocha Test case over a cordova app. I am triggering click event to open inapp browser. Once inapp browsers gets opened I am trying to log the count of available handles and I am getting two separate handles. Upon invoking switchTo api to second handle I am getting a timeout error and operation doesn’t succeed successfully.
Environment:
- Appium version (or git revision) that exhibits the issue: 1.5.1
- Last Appium version that did not exhibit the issue (if applicable): N/A
- Desktop OS/version used to run Appium: MacOS Mojave 10.14.6
- Mobile platform/version under test: iOS 12.1
- Real device or emulator/simulator: Simulator
- Appium CLI or Appium.app|exe: Appium.app
Appium Logs: https://gist.github.com/manish2788/a0a392f4e699dc7a0415113cb0618db0
Code To Reproduce Issue
import {Builder, By, until} from 'selenium-webdriver';
describe('Test Sample App', function() {
let opts = {
host: 'localhost',
port: 4723,
iOSDesiredCapabilities: {
platformName: "iOS",
platformVersion: "12.1",
deviceName: "iPhone XR",
app: "/Users/kmanikum/Desktop/Workspaces/cordova-plugin/apps/cs-app/HelloWorld.app",
automationName: "Appium",
browserName: '',
autoWebview: true
}
};
const serverAddress = "http://0.0.0.0:4723/wd/hub";
const driver = new Builder().usingServer(serverAddress).withCapabilities(opts.iOSDesiredCapabilities).build();
beforeEach(async function() {
console.log("Starting Test...");
this.timeout(30000);
//await driver.wait(until.elementLocated(By.id("globalBody")));
await driver.wait(until.elementLocated(By.id("deviceready")));
});
it('example', async function() {
console.log("My First Test Case");
const loginButton = await driver.wait(driver.findElement(By.id("openPage")));
await loginButton.click();
await driver.sleep(10000);
const allHandles = await driver.getAllWindowHandles();
console.log(allHandles);
await driver.switchTo().window(allHandles[1]);
});
afterEach(async function() {
await driver.quit();
});
});
Error Log upon running above test upon invocation of switchTo :
Test Sample App
Starting Test...
1) "before each" hook for "example"
0 passing (48s)
1 failing
1) Test Sample App
"before each" hook for "example":
Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/kmanikum/Desktop/Workspaces/cordova-plugin/apps/cs-app/sample.js)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)