Reputation: 163
I am using Appium, UIAutomator2, webdriverio and JavaScript to test an app which is running on a virtual device.
I search for an element and set (or in this case clear) its value.
Using class selector it works fine.
const codeField = await driver.$("android.widget.EditText");
await codeField.clearValue();
But I would like to find the element by id, so I have this:
const codeField = await driver.findElement("id", "de.abcdef.ghijkl:id/activation_code_input");
await codeField.clearValue();
It results in:
webdriver: COMMAND findElement("id", "de.abcdef.ghijkl:id/activation_code_input")
webdriver: [POST] http://127.0.0.1:4723/wd/hub/session/f0a6844b-55e0-468d-b165-14cb219e55f7/element
webdriver: DATA {using: 'id', value: 'de.abcdef.ghijkl:id/activation_code_input'}
webdriver: RESULT {element-6066-11e4-a52e-4f735466cecf: '5d56ef1d-0036-4ecf-8b26-f060e290510b', ELEMENT: '5d56ef1d-0036-4ecf-8b26-f060e290510b'}
and finally, when it should set the value of the field
TypeError: codeField.clearValue is not a function
Am I missing anything?
Upvotes: 0
Views: 1139
Reputation: 163
For some reason the webdriverio is not able to resolve the retrieved element correctly when I use findElement("id", ...) or findElement("xpath", ...). As I would like to address the element by id resp. resource-id instead of the class, I could solve it by passing the resource-id using xpath syntax
const codeField = await driver.$('//*[@resource-id="de.abcdef.ghijkl:id/activation_code_input"]');
Upvotes: 1