Gbru
Gbru

Reputation: 1087

Webdriverio element not clickable at point?

Im currently attempting to click on a checkbox button.

DOM code of the element:

<label><input type="checkbox" value="option-1">Option 1</label>

I have created the following test using WebdriverIO and Mocha:

  it("Click on checkbox button", () => {
    browser.pause(5000);
    const clickByXpathSelector = $("//div[@id='checkboxes']//input[@value='option-1']");
    clickByXpathSelector.waitForDisplayed();
    clickByXpathSelector.scrollIntoView();
    clickByXpathSelector.click();
    expect(clickByXpathSelector.isExisting()).to.be.true;
    expect(clickByXpathSelector.isSelected()).to.be.false;
    expect(clickByXpathSelector.isDisplayed()).to.be.true;
    browser.pause(5000);
  });

Exception message:

unknown error: Element <input type="checkbox" value="option-1"> is not clickable at point (432, 220). Other element would receive the click: <p>...</p>

The element is clearly in view for it to be interactable and the element not housed within an iframe.

Any ideas?

Upvotes: 1

Views: 7098

Answers (1)

Shubham Jain
Shubham Jain

Reputation: 17593

First try to use Action class to click on element in webdriverio. Also add some explicit waits

If still not work use below code:

// clicks on element using JavaScript
browser.addCommand("jsClick", function(this: ElementResult) {
  this.then((element) => {
    browser.execute("arguments[0].click();", element.value);
  });
});

Above code click using addCommand which is similar to selenium JavaScriptExecutor.

Source about addCommand:

http://webdriver.io/api/utility/addCommand.html

Upvotes: 1

Related Questions