dharls
1
Hi. I’m new to Appium so apologies if this seems like a very basic user error
I’m using Appium to test an app via Browserstack, and need to click on an element.
So my code at the moment is;
const okButton = driver.elementById('android:id/button1');
okButton.click();
However, when I run this, I get the following error;
TypeError: okButton.click is not a function
Any ideas on what I’m doing wrong?
thanks.
wreed
2
Can you run locally? Nobody here can test Browserstack without paying for it.
dharls
3
Thanks for the reply @wreed. I’ve now got this working. I’d forgot the async command.
1 Like
wreed
4
I’m glad you’ve gotten it working. I’m curious if the async command is a Browserstack thing? I’m not familiar with it.
dharls
5
Sorry, I should have expanded my answer.
This is my working code;
driver.init(desiredCaps)
.then (async function () {
let element = await driver.element("xpath",
".//android.widget.Button[@text='OK']");
await element.click();
})
.fin(function() {
return driver.quit();
})
.done();
wreed
6
Ah, I think that’s Javascript. Thanks!