codeceptjs / codeceptjs/CodeceptJS
Appium Helper: I.seeElement use "xPath" to find element, even though using strict locator "className"
- 主要言語
- JavaScript
- スター
- 4.2k
- フォーク
- 757
- 平均マージ
- 2日 9時間
- マージ済み PR(30日)
- 16
説明
#### 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'
}
```
コントリビューションガイド
調査の方向性
提供された className シナリオを Appium ヘルパーで再現し、I.seeElement のエントリーポイントと locator の処理を調査します。要求された className 戦略と、Appium ログに示されている XPath リクエストを比較します。動作が修正されるか、明確にドキュメント化され、回帰テストでカバーされれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript
- 領域
- mobile-dev, testing-qa
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100