Ask Your Question

Revision history [back]

To set up Appium with WebdriverIO, you can follow these steps:

Step 1: Install Node.js

First, you need to install Node.js on your computer.

Step 2: Install Appium

Install Appium using the npm package manager. You can do this by running the following command in your terminal:

npm install -g appium

Step 3: Install WebdriverIO

Install WebdriverIO using the npm package manager. You can do this by running the following command in your terminal:

npm install webdriverio --save-dev

Step 4: Set up a basic WebdriverIO configuration file

Create a new file called wdio.conf.js in your project directory and copy the following code:

exports.config = {
  //
  // ====================
  // Appium Configuration
  // ====================
  //
  services: ['appium'],
  appium: {
    // port: 4723,
    // ...
    // See https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/caps.md for all capabilities
  },

  //
  // ==================
  // Specify Test Files
  // ==================
  //
  specs: [
    './test/**/*.js'
  ],
  // ...
  // ...
}

Step 5: Create a test file

Create a new folder called test in your project directory and create a new file called example.test.js inside it. Copy the following code into it:

const assert = require('assert');

describe('My App', () => {
  it('should open the app and display the title', () => {
    browser.url('myapp://');
    const title = browser.getTitle();
    assert.strictEqual(title, 'My App');
  });
});

This test will open the "My App" app (replace "myapp://" with the correct app URL scheme for your app) and check that the title is correct.

Step 6: Run the test

Start the Appium server by running the command appium in your terminal.

Then, run the following command in your terminal to run the test:

npx wdio wdio.conf.js

This command will start the Chrome browser and run the test.

Congratulations! You have successfully set up Appium with WebdriverIO.