1

I'm trying to run a simple e2e test on my React Native project using Appium, but can't seem to get it working. I can start the Appium server with no errors, and running appium-doctor shows only a couple warnings for optional dependencies, but otherwise it's fine.

I'm using the Espresso driver with Webdriver for the client. I installed the required dependencies npm install --save-dev webdriverio @wdio/cli and set up my config file in the root of the project (wdio.conf.js) which looks like this:

exports.config = {
  port: 4723,
  specs: ["./test/specs/**/*.js"],
  exclude: [
    // 'path/to/excluded/files'
  ],
  maxInstances: 10,
  capabilities: [
    {
      maxInstances: 5,
      browserName: "chrome",
      acceptInsecureCerts: true,
    },
  ],
  logLevel: "info",
  bail: 0,
  baseUrl: "http://localhost",
  waitforTimeout: 10000,
  connectionRetryTimeout: 120000,
  connectionRetryCount: 3,
  services: ["chromedriver", "appium"],
  framework: "jasmine",
  reporters: ["spec"],
  jasmineOpts: {
    defaultTimeoutInterval: 60000,
    expectationResultHandler: function (passed, assertion) {
      // do something
    },
  },
};

I have the Metro bundler running, and my app running in an emulator, but can't seem to get my e2e tests to run properly. Here is what my test file looks like:

const wdio = require("webdriverio");

const opts = {
  path: "/wd/hub",
  port: 4723,
  capabilities: {
    platformName: "Android",
    platformVersion: "9",
    deviceName: "Pixel API 28 AOSP",
    app: "./android/app/build/outputs/apk/flavor/debug/app-flavor-debug.apk",
    appPackage: "io.appium.android.apis",
    appActivity: ".MainActivity",
    automationName: "Espresso",
  },
};

async function main() {
  const client = await wdio.remote(opts);

  const header = await client.$("~header"); // query by accesibilityLabel
  await expect(header).toBeDisplayed(); // item is visible on the current screen

  await client.deleteSession();
}

main();

When I run npx wdio run ./wdio.conf.js this is what I get printed out:

@wdio/local-runner: Run worker command: run
webdriver: Initiate new session using the WebDriver protocol
webdriver: [POST] http://127.0.0.1:4723/wd/hub/session
webdriver: DATA {
  capabilities: {
    alwaysMatch: {
      platformName: 'Android',
      platformVersion: '9',
      deviceName: 'Pixel API 28 AOSP',
      app: './android/app/build/outputs/apk/flavor/debug/app-flavor-debug.apk',
      appPackage: 'io.appium.android.apis',
      appActivity: '.MainActivity',
      automationName: 'Espresso'
    },
    firstMatch: [ {} ]
  },
  desiredCapabilities: {
    platformName: 'Android',
    platformVersion: '9',
    deviceName: 'Pixel API 28 AOSP',
    app: './android/app/build/outputs/apk/flavor/debug/app-flavor-debug.apk',
    appPackage: 'io.appium.android.apis',
    appActivity: '.MainActivity',
    automationName: 'Espresso'
  }
}
webdriver: Request failed with status 404 due to The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource
@wdio/cli: [0-0] SKIPPED in chrome - /test/specs/example.e2e.js
@wdio/cli:launcher: Run onComplete hook

Spec Files:  0 passed, 1 skipped, 1 total (100% completed) in 00:00:01

@wdio/local-runner: Shutting down spawned worker
@wdio/local-runner: Waiting for 0 to shut down gracefully
@wdio/local-runner: shutting down

I tried this and this, but still have the same issue.

Attila
  • 1,097
  • 2
  • 19
  • 45

0 Answers0