'Codeceptjs: I got ERROR webdriver: Request failed with status 404 due to unknown command when trying to click to an mobile element

When I tried to click an element using Appium and Codeceptjs, I got the error below:

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. 

Full log below:

-- FAILURES:

  1) login
       test something:
     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 getErrorFromResponseBody (C:\Users\DELL\node_modules\webdriver\build\utils.js:197:12)
      at NodeJSRequest._request (C:\Users\DELL\node_modules\webdriver\build\request\index.js:158:60)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)
      at async Browser.wrapCommandFn (C:\Users\DELL\node_modules\@wdio\utils\build\shim.js:137:29)

  Scenario Steps:
  - I.click("//android.widget.Button[@content-desc="Login"]/android.widget.TextView[2]") at Test.<anonymous> (.\login_test.js:9:7)
  - I.seeAppIsInstalled("com.wdiodemoapp") at Test.<anonymous> (.\login_test.js:8:7)

This error log appears when the codeceptjs call I.click() api I think. I tried use Accesibility ID and Xpath to get element but get the same error

My test code:

Feature('login');
const LOGIN_ICON = '~Login'
const LOGIN_BTN = '~button-LOGIN'
const EMAIL_TXT_FIELD = '~input-email'
const PASSWORD_TXT_FIELD = '~input-password'

Scenario('test something', ({ I }) => {
    I.seeAppIsInstalled("com.wdiodemoapp")
    I.click('//android.widget.Button[@content-desc="Login"]/android.widget.TextView[2]')
    I.fillField(EMAIL_TXT_FIELD, "abc")
    I.fillField(PASSWORD_TXT_FIELD, "12345678")
    I.click(LOGIN_BTN)

});

Below are my config file:

exports.config = {
  tests: './*_test.js',
  output: './output',
  helpers: {
    Appium: {
      platform: 'Android',
      device: 'emulator',
      desiredCapabilities: {
        appPackage: "com.wdiodemoapp",
        appActivity: "MainActivity",
        deviceName: "emulator-5554",
        platformName: "Android",
        automationName: "UiAutomator2",

      }
    }
  },
  include: {
    I: './steps_file.js'
  },
  bootstrap: null,
  mocha: {},
  name: 'codecept-mobile-auto'
}

Any idea please !!! I am the new to codeceptjs testing tool Thank a lot



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source