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

1

There are 1 best solutions below

0
On

I had two things I had to do to fix this issue:

  1. I needed the platform to be set to 'android' instead of 'Android'. It looks like codecept does a case sensitive check on whether to run the Touch click or Element click. If I'm reading the code right, you can see it in this line from their WebDriver.js file.
const clickMethod = this.browser.isMobile && this.browser.capabilities.platformName !== 'android' ? 'touchClick' : 'elementClick';

If you look through the Appium calls, this changes the API from /touch/click to /element/:elementid/click which works correctly.

  1. Not sure if this was necessary, but I did run an npm update / npm install to refresh all of my packages. This was after updating to the latest version of appium.

Hope this helps and someone else doesn't have to beat their head against this wall.