5

I am getting the following error from my webdriverIO selenium code when I try to run it:

Failed: unknown error: Element is not clickable at point (389, 709). Other element would receive the click: < html lang="en" >...< /html >

here's the relevant code:

const checkboxSelector = 
    getAttributeSelector('data-test', 'manual-checkbox');
browser.click(checkboxSelector);

How do I get rid of this error?

--- ADDITIONAL INFO ---

The test is being run with chromedriver:

var desktop = exports.desktop = [{
    browser: 'Chrome',
    os: 'Windows',
    os_version: '7'
}];
ThinkBonobo
  • 12,631
  • 8
  • 48
  • 68

2 Answers2

1

Seems like the issue was that you needed to scroll to the appropriate element explicitly to click the button. Not sure why it's not automatic but it's an easy fix using browser.scroll(selector) (http://webdriver.io/api/utility/scroll.html).

const checkboxSelector = 
    getAttributeSelector('data-test', 'manual-checkbox');
browser.scroll(checkboxSelector);
browser.click(checkboxSelector);

Problem solved

ThinkBonobo
  • 12,631
  • 8
  • 48
  • 68
  • That's a hack, not a solution. I'm guessing you are running your tests on non-Chrome browsers (had this issue with `geckodriver` several times). Can you update your question with the `package.json` dependencies & setup you're running your checks against? On `chromedriver` for example, the `.click()` command automatically scrolls to the `element` until it is visible in the `viewport`. – iamdanchiv Nov 19 '17 at 11:35
  • Thanks for taking a look. How did you solve your issue on geckodriver? Unfortunately, even though you're saying chromedriver automatically scrolls to the element it was not doing that in my case. I am using chromedriver for my test. Can't add the package.json because there's too much other stuff going on but I added some relevent configuration info. – ThinkBonobo Nov 22 '17 at 02:29
1

Does your page potentially have hidden elements or multiple elements that you may be targeting with your selector? When I've seen this error, often times my single selector could behind the scenes be targeting another element. The message "Other element would receive the click" was often the key to indicating that it may have picked up multiple elements and the Element you had intended to click, was not what the script would have clicked.

You can test this by using your CSS Selector in the browser console with

$$('data-test')

If you see multiple elements returned, you may need to be more specific with your Selector to more precisely narrow down the one you intend to act on.

Denzik
  • 281
  • 1
  • 7
  • This was actually my first thought @Denzik. But when I looked at the page there is nothing in front of it. However, it was out of the viewport which prevented clicking. – ThinkBonobo Nov 22 '17 at 02:23
  • @ThinkBonobo have you solved this? The click() with webdriverIO should correctly find the element then click without having to scroll to it. Especially in the newer version of ChromeDriver and WebdriverIO if you haven't updated lately. – Denzik Nov 23 '17 at 20:39
  • Hey denzik, the data test tagged attributes that I was creating are unique to a single element on the page. I can't really update the packages at this time because they reside in a common configuration library and other users may be using them. It's very possible that if I upgrade webdriver / chromedriver I won't need the scroll() command before clicking at a button down the viewport but for now I'll leave it in since it's not hurting. – ThinkBonobo Nov 26 '17 at 15:51