Skip to content

Appium Helper: I.seeElement use "xPath" to find element, even though using strict locator "className" #1865

Open
@hoang-pham

Description

@hoang-pham

What are you trying to achieve?

I have implemented script used strict locator "className" with value is "xPath".
I think the test will be failed. But it passed.
Is it a CodeceptJS 's issue?

What do you get instead?

Codeceptjs log:

className --
    [1] Starting recording promises
    Emitted | suite.before ([object Object])
  className
    Emitted | test.before ([object Object])
    Emitted | test.start ([object Object])
    Emitted | step.before (I see element {"className":"//android.widget.TextView[@text='Display']"})
    Emitted | step.after (I see element {"className":"//android.widget.TextView[@text='Display']"})
    Emitted | step.start (I see element {"className":"//android.widget.TextView[@text='Display']"})
    I see element {"className":"//android.widget.TextView[@text='Display']"}
    » [SmartWait (5000ms)] Locating //android.widget.TextView[@text='Display'] in 5000
    Emitted | step.passed (I see element {"className":"//android.widget.TextView[@text='Display']"})
    Emitted | step.finish (I see element {"className":"//android.widget.TextView[@text='Display']"})
    Emitted | test.passed ([object Object])
    Emitted | test.finish ([object Object])
  √ OK in 1424ms

    Emitted | test.after ([object Object])
    Emitted | suite.after ([object Object])

  OK  | 1 passed   // 12s
    Emitted | global.result ([object Object])
    Emitted | global.after ([object Object])

Appium log:

[HTTP] --> POST /wd/hub/session/937bfb2b-9ef4-4257-8abf-d1a911a7a6ea/elements
[HTTP] {"using":"xpath","value":"//android.widget.TextView[@text='Display']"}
[W3C (937bfb2b)] Calling AppiumDriver.findElements() with args: ["xpath","//android.widget.TextView[@text='Display']","937bfb2b-9ef4-4257-8abf-d1a911a7a6ea"]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Waiting up to 5000 ms for condition
[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.TextView[@text='Display']","context":"","multiple":true}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.TextView[@text='Display']","context":"","multiple":true}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '//android.widget.TextView[@text='Display']' using 'XPATH' with the contextId: '' multiple: true
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '//android.widget.TextView[@text='Display']' using 'XPATH' with the contextId: '' multiple: true
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":[]}
[AndroidBootstrap] Received command result from bootstrap
[BaseDriver] Waited for 615 ms so far
[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.TextView[@text='Display']","context":"","multiple":true}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.TextView[@text='Display']","context":"","multiple":true}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '//android.widget.TextView[@text='Display']' using 'XPATH' with the contextId: '' multiple: true
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CLASS=android.widget.TextView, INSTANCE=11]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[CLASS=android.widget.TextView, INSTANCE=11]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Selector ends with instance.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":[{"ELEMENT":"1"}]}
[AndroidBootstrap] Received command result from bootstrap
[W3C (937bfb2b)] Responding to client with driver.findElements() result: [{"element-6066-11e4-a52e-4f735466cecf":"1","ELEMENT":"1"}]
[HTTP] <-- POST /wd/hub/session/937bfb2b-9ef4-4257-8abf-d1a911a7a6ea/elements 200 1285 ms - 69

Test source code:

Feature("className");

Scenario("className", (I) => {
    I.seeElement({ className: "//android.widget.TextView[@text='Display']" });
});

Details

  • CodeceptJS version: 2.3.0
  • NodeJS Version: 10.16.0
  • Operating System: Window 10
  • WebDriverIO: 5.12.5
  • Configuration file:
exports.config = {
  tests: './*_test.js',
  output: './output',
  helpers: {
     Appium: {
      platform: 'Android',
      device: 'emulator',
      smartWait: 5000,
      desiredCapabilities: {
        appPackage: "com.android.settings",
        appActivity: ".Settings",
      }
    }
  },
  include: {},
  bootstrap: null,
  mocha: {},
  name: 'codeceptjs'
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions