codeceptjs / codeceptjs/CodeceptJS

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

Abierto
#1,865 0 comentarios 0 reacciones 0 asignados Ver en GitHub
appium locator
Lenguaje dominante
JavaScript
Estrellas
4.2k
Forks
757
Merge medio
2 d 9 h
PR fusionados (30 d)
16

Descripción

#### 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:

```bash
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:

```bash
[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:

```js
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:

```js
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'
}
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.