Sarah
Sarah

Reputation: 349

Selenium: Element not clickable … Other Element Would Receive Click, click anyway

The long and short of this is when I try to use

return this.driver.findElement(By.css("div[class*='img']")).click();

I get an error Uncaught WebDriverError: unknown error: Element is not clickable at point (525, 889). Other element would receive the click:...

How can I click anyway and let the "other element" receive the click? I'm using webdriverjs.

The reasoning behind this is basically the website I'm testing does some fancy react stuff which obscures the link somehow. Basically instead of attaching a link to an image, the entire image is covered with a transparent box that links you somewhere (don't ask me why). When you "click the image" you aren't actually clicking the image, but from a user point of view they are one and the same.

When I was using webdriverIO I could say

browser.moveToObject("img"); browser.leftClick();

but we're moving away from that. I've also tried

this.driver.findElement(By.css("div[class*='img']"));
    return this.driver.actions().click().perform();

but it doesn't seem to do anything.

There have been a lot of questions about this error, but I haven't seen any that want you to click anyway.

Upvotes: 5

Views: 2193

Answers (1)

Sarah
Sarah

Reputation: 349

In a classic case of looking for an answer for hours, posting a question, and immediately finding an answer after, I found a work around:

var mylink = this.driver.findElement(By.css("div[class*='img']"));
return this.driver.executeScript("arguments[0].click();", mylink);

Upvotes: 6

Related Questions