0

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: enter image description here

Ramprasath Selvam
  • 3,868
  • 3
  • 25
  • 41
Grubsniff
  • 1
  • 1

1 Answers1

1

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();
Ray
  • 1,134
  • 10
  • 27