I follow this tutorial to set up testing in my app with appium and webdriver.
my wdio.config is
exports.config = {
services: ['appium'],
port: 4723,
runner: 'local',
specs: ['./tests/*.js'],
capabilities: [
{
maxInstances: 1,
browserName: '',
appiumVersion: '1.20.2',
platformName: 'Android',
platformVersion: '11',
deviceName: '99211FFAZ00843',
app: './apps/app-dev-debug.apk',
automationName: 'UiAutomator2',
},
],
logLevel: 'trace',
bail: 0,
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
framework: 'mocha',
reporters: ['spec'],
mochaOpts: {
ui: 'bdd',
timeout: 60000,
},
};
package.json
{
"name": "automationTests",
"version": "1.0.0",
"description": "",
"main": "wdio.conf.js",
"directories": {
"test": "tests"
},
"dependencies": {
"@wdio/cli": "^7.0.5",
"chai": "^4.3.0",
"wdio-appium-service": "^0.2.3",
"webdriverio": "^7.0.5"
},
"devDependencies": {
"@wdio/local-runner": "^7.0.5",
"@wdio/mocha-framework": "^7.0.4",
"@wdio/spec-reporter": "^7.0.4",
"@wdio/sync": "^7.0.5",
"chromedriver": "^88.0.0",
"wdio-chromedriver-service": "^6.0.4"
},
"scripts": {
"test": "mocha"
},
"keywords": [],
"author": "",
"license": "ISC"
}
I have tests folder with test file App.test.js
const TestsIds = require('../../../src/assets/test_ids');
var expect = require('chai').expect;
describe('Simple App testing', () => {
beforeEach(() => {});
it('Valid Login Test', () => {
const skipButton = $(`~$view-app-id`).waitForDisplayed(3000, false);
skipButton.click();
});
});
I got this error
ERROR webdriver: Request failed with status 404 due to unknown command: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource
[0-0] 2021-02-18T12:34:11.688Z ERROR webdriver: unknown command: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource
at Object.getErrorFromResponseBody (/Users/XXX/Desktop/projects/XXXXX/node_modules/webdriver/build/utils.js:189:12)
at WebDriverRequest._request (//Users/XXX/Desktop/projects/XXXXX/node_modules/webdriver/build/request.js:168:31)
at process._tickCallback (internal/process/next_tick.js:68:7)
[0-0] 2021-02-18T12:34:11.690Z ERROR @wdio/runner: Error: Failed to create session.
The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource
at Object.startWebDriverSession (//Users/XXX/Desktop/projects/XXXXX/node_modules/webdriver/build/utils.js:68:15)
at process._tickCallback (internal/process/next_tick.js:68:7)
2021-02-18T12:34:11.810Z DEBUG @wdio/local-runner: Runner 0-0 finished with exit code 1
[0-0] FAILED in undefined - /tests/App.test.js
2021-02-18T12:34:11.811Z INFO @wdio/cli:launcher: Run onComplete hook
Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:00:01
in addition I get error in the app.test.js
skipButton.click() is not function
Find configurations here : https://webdriver.io/docs/options/#webdriver-options
you need to change configuration file like this :
exports.config = {
services: ['appium'],
port: 4723,
// PATH is important for appium local server :
path: '/wd/hub/',
runner: 'local',
specs: ['./tests/*.js'],
capabilities: [
{
maxInstances: 1,
browserName: '',
appiumVersion: '1.20.2',
platformName: 'Android',
platformVersion: '11',
deviceName: '99211FFAZ00843',
app: './apps/app-dev-debug.apk',
automationName: 'UiAutomator2',
},
],
logLevel: 'trace',
bail: 0,
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
framework: 'mocha',
reporters: ['spec'],
mochaOpts: {
ui: 'bdd',
timeout: 60000,
},
};
In order to expect something from your test, try this update for your App.test.js :
const expect = require('chai').expect;
const TestsIds = require('../../../src/assets/test_ids');
const delay = millis => new Promise((resolve, reject) => {
setTimeout(_ => resolve(), millis)
});
describe('Simple App testing', () => {
// Adding time (20sec) to make sure the app is load prior to test is run
before(async () => {
await delay(20000);
});
it('My first test', async => {
// here we uss waitForDisplayed with default settings from wdio.conf.js
$('~[YourAccessibilityLabel]').waitForDisplayed();
// make sure [YourAccessibilityLabel] exist with simple expect :
let isHome = $('~[YourAccessibilityLabel]').isExisting();
expect(isHome).to.equal(true);
// then click to continue your app testing
skipButton.click();
});
});