最新消息:20210917 已从crifan.com换到crifan.org

【已解决】Selenium出错:Message unknown error Element button is not clickable at point

selenium crifan 4590浏览 0评论

Selenium中Python用代码:

placeOrderElement = WebDriverWait(driver, gCfg[“waitTimeout”]).until(EC.element_to_be_clickable(

    (By.XPATH, ‘//div[contains(@class, “order-call-to-action”)]/button[contains(@class, “cli-purchase”)]’)))

logging.debug(“placeOrderElement=%s”, placeOrderElement)

logging.info(“Found ‘Place Order’ button”)

placeOrderElement.click()

出错:

    placeOrderElement.click()

  File “/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py”, line 80, in click

    self._execute(Command.CLICK_ELEMENT)

  File “/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py”, line 501, in _execute

    return self._parent.execute(command, params)

  File “/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py”, line 308, in execute

    self.error_handler.check_response(response)

  File “/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py”, line 194, in check_response

    raise exception_class(message, screen, stacktrace)

selenium.common.exceptions.WebDriverException: Message: unknown error: Element <button type=”button” tabindex=”0″ data-m=”{&quot;aN&quot;:&quot;shoppingCart&quot;,&quot;cN&quot;:&quot;PlaceOrder&quot;,&quot;bhvr&quot;:80}” id=”ember2045″ class=”btn theme-default btn-primary cli-purchase ember-view”>…</button> is not clickable at point (919, 349). Other element would receive the click: <section style=”display: block;” id=”ember593″ class=”busyContainer ember-view”>…</section>

  (Session info: chrome=62.0.3202.94)

  (Driver info: chromedriver=2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2),platform=Mac OS X 10.13.1 x86_64)

但是此处确保是:可以获取可以点击的按钮了。

但是点击却还是报错

怀疑是:网页内部做了故意的页面向下移动,使得元素的位置不可点击了?

selenium Message unknown error Element button is not clickable at point

google chrome – Debugging “Element is not clickable at point” error – Stack Overflow

Chrome – Element is not clickable at point · Issue #2766 · SeleniumHQ/selenium-google-code-issue-archive

Element is not clickable at point – Scroll to click now mandatory? · Issue #566 · SeleniumHQ/docker-selenium

说是2.32的chromedriver解决了该bug -》 但是自己这里是2.33了。

Element is not clickable at point · Issue #1867 · SeleniumHQ/selenium

Element is not clickable at point SeleniumWebdriverException | Selenium Easy

Element is not clickable at point (1307, 27) would like to know more about this type of error – Support: Products & Agents / Synthetics – New Relic Explorer’s Hub

Element is not clickable at point (…). Other element would receive the click – Google Groups

先去滚动到对应的y的位置,再去点击试试

8. Appendix: Frequently Asked Questions — Selenium Python Bindings 2 documentation

selenium busycontainer Message unknown error Element button is not clickable at point

python – Selenium-Debugging: Element is not clickable at point (X,Y) with Firefox driver – Stack Overflow

还是去试试那个,用js脚本执行,去点击

python – Selenium: Element not clickable at point (x, y) – Stack Overflow

不过突然注意到了:

Other element would receive the click: <section style=”display: block;” id=”ember593″ class=”busyContainer ember-view”>…</section>

貌似是:

此处页面会出现一个半透明的图层,正在加载 -》 所以导致对应的元素无法被点击

-〉所以要去想办法等待这个图层消失才能点击。

所以去调试,等待图层消失。

【已解决】Selenium中如何判断等到某个元素消失不可见

然后就可以点击了。

【总结】

此处虽然用element_to_be_clickable找到了可以点击的button,但是点击却还会出错:

selenium.common.exceptions.WebDriverException: Message: unknown error: Element <button type=”button” …..PlaceOrder…..</button> is not clickable at point (919, 349).

的原因是:

button的上层有个overlay的,正在加载的,忙的提示层,所以点击无法点到下面的button

而找到问题的思路是:

其实错误提示中有:

Other element would receive the click: <section style=”display: block;” id=”ember593″ class=”busyContainer ember-view”>…</section>

解决办法是:

此处busy的overlay,过段时间就消失了,然后就可以点击到button了。

所以用:

【已解决】Selenium中如何判断等到某个元素消失不可见

中的

<code>busyContainerElementInvisible = WebDriverWait(driver, gCfg["waitTimeout"] * 2).until(EC.invisibility_of_element_located(
    (By.XPATH, '//section[contains(@class, "busyContainer")]')))
# wait from:
# &lt;section style="display: block;" id="ember593" class="busyContainer ember-view x-hidden-focus"&gt;
# to:
# &lt;section style="display: none;" id="ember593" class="busyContainer ember-view x-hidden-focus"&gt;
</code>

即可等待overlay消失,然后再去点击button就OK了。

转载请注明:在路上 » 【已解决】Selenium出错:Message unknown error Element button is not clickable at point

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
94 queries in 0.180 seconds, using 23.33MB memory