I’ve just setup Appium with Webdriverio and I am having a trouble waiting for the element.
Session ends as soon as app is opened, and I can see from Appium logs that it waits 0ms for the element.
This is my test file login.test.js:
const welcome = require("../../pageObjects/welcome.page");
describe("Login", () => {
it("Verify user can login", () => {
driver.setImplicitTimeout(10000); // tried with implicit wait
driver.pause(3000); // and with explicit wait
welcome.signInBtn.click();
});
});
welcome.page.js file:
class WelcomePage {
/**
* Define Elements
*/
get signInBtn() {
return $("~Sign in");
}
}
module.exports = new WelcomePage();
package.json file:
{
"name": "appium_js",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "./node_modules/.bin/wdio wdio.conf.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"@wdio/cli": "^7.16.13"
},
"devDependencies": {
"@wdio/local-runner": "^7.16.13",
"@wdio/mocha-framework": "^7.16.13",
"@wdio/selenium-standalone-service": "^7.16.13",
"@wdio/spec-reporter": "^7.16.13",
"@wdio/sync": "^7.16.13"
}
}
wdio.conf.js file:
let { join } = require("path");
exports.config = {
runner: "local",
port: 4723,
path: "/wd/hub",
specs: ["./test/specs/**/*.js"],
maxInstances: 1,
capabilities: [
{
platformName: "Android",
"appium:deviceName": "Pixel XL API 31",
"appium:app": join(process.cwd(), "./app-dev-debug.apk"),
},
],
logLevel: "info",
bail: 0,
baseUrl: "http://localhost",
waitforTimeout: 0,
connectionRetryTimeout: 120000,
connectionRetryCount: 3,
services: ["selenium-standalone"],
framework: "mocha",
reporters: ["spec"],
mochaOpts: {
ui: "bdd",
timeout: 60000,
}
};
Appium logs:
[W3C (10484f32)] Calling AppiumDriver.findElement() with args: ["accessibility id","Sign in","10484f32-220b-4a22-ae39-9b7c6ff9adfb"]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, css selector, -android uiautomator
[BaseDriver] Waiting up to 0 ms for condition
[WD Proxy] Matched '/element' to command name 'findElement'
[WD Proxy] Proxying [POST /element] to [POST http://127.0.0.1:8201/wd/hub/session/0b87b7c0-9b19-48ce-9e6e-02c6d5cc8d08/element] with body: {"strategy":"accessibility id","selector":"Sign in","context":"","multiple":false}
[HTTP] --> DELETE /wd/hub/session/10484f32-220b-4a22-ae39-9b7c6ff9adfb
[HTTP] {}
[W3C (10484f32)] Calling AppiumDriver.deleteSession() with args: ["10484f32-220b-4a22-ae39-9b7c6ff9adfb"]
[BaseDriver] Event 'quitSessionRequested' logged at 1642100255280 (19:57:35 GMT+0100 (Central European Standard Time))
[Appium] Removing session 10484f32-220b-4a22-ae39-9b7c6ff9adfb from our master session list
[UiAutomator2] Deleting UiAutomator2 session
[UiAutomator2] Deleting UiAutomator2 server session
[WD Proxy] Matched '/' to command name 'deleteSession'
[WD Proxy] Proxying [DELETE /] to [DELETE http://127.0.0.1:8201/wd/hub/session/0b87b7c0-9b19-48ce-9e6e-02c6d5cc8d08] with no body
Not sure why it doesn’t wait for the element as I’ve tried with implicit and explicit waits? Maybe it has do to with the driver?