Reputation: 1
I'm currently trying to script some automation tests.
I've hit a block with what should be a simple checkbox click...
The issue is the test run passes the step, but in the browser the "click" hasn't actually occurred.
POM
optionClick(optionValue){
const option = $('//input[@type="checkbox"]').$('..').$('label').$('//span[contains(text(), "'+optionValue+'")]');
option.waitForDisplayed(2000);
const optionSelect = $('//input[@type="checkbox"]').$('..').$('label').$('//span[contains(text(), "'+optionValue+'")]');
optionSelect.click();
}
Feature is - And I select the 'Create' option
the html element I'm trying to click is as follows:
Upvotes: 0
Views: 208
Reputation: 1214
The click function is asynchronous. If you don't do an await or wrap the click call in a promise then the action will take place synchronously meaning your test will move on and will probably finish before the click actually takes place.
What you need to do is:
await optionSelect.click();
Upvotes: 1