Watir-webdriver throws 'not clickable' error even when element is visible, present

你。 提交于 2019-12-05 12:45:47

You can do a click at any element without getting it visible. Check this out:

link.fire_event('click')

BUT It is very very very not good decision as far as it will click the element even if it is not actually visible or in case when it is just impossible to click it (because of broken sticky footer for example).

That's why much better to wait the fooler, scroll the page and then click like:

browser.div(id: "footerMessageArea").wait_until_present
browser.execute_script("window.scrollTo(0, document.body.scrollHeight);")
link.click

The sticky footer is blocking webdriver from performing the click, hence the message that says 'other element would receive the click'.

There are several different ways you can get around this.

  1. Scroll down to the bottom of the page before the click
  2. Hide/Delete the sticky footer before any/all link clicks
  3. Focus on an element below the element you want to click before you perform the click
Shasak Singh Sengar

I Guess your element is visible in the screen.

Before clicking on the element first you have to scroll the webpage so that element is visible then perform the click. Hope it should work.

I had similar issue, I just used following javascript code with watir:

link = browser.link(text: "Full website")
@browser.execute_script("arguments[0].focus(); arguments[0].click();", link)

Sometimes I have to use .click! which i believe is the fire_event equivalent. Basically something is layered weird, and you just have to go around the front end mess.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!