硒python

时间:2018-12-15 23:19:02

标签: python selenium

这是更详细的消息:

selenium.common.exceptions.ElementClickInterceptedException: Message: Element <a class="card-product__btn" href="/shop/iqos/offers/297/"> is not clickable at point (452.0333251953125,853.566650390625) because another element <div class="footer__warning"> obscures it

首先,我想了解测试是否有问题或仅仅是我正在测试的网站上的错误。从该消息来看,这似乎是该网站上的错误,但我不确定。

这是测试的样子:

   def test_add_to_basket(self):
        element = WebDriverWait(self.driver, 60).until(
        EC.element_to_be_clickable((By.XPATH, "//div[.//text()='someTextHere']/a[@class='card-product__btn']")))
        element.click()

我知道这不是一个完全有效的测试,但是应该以“通过”状态终止。

我正在使用Firefox驱动程序,而当我使用Chrome驱动程序时,我收到以下异常:

selenium.common.exceptions.WebDriverException: Message: unknown error: Element <a class="card-product__btn" href="/shop/iqos/offers/297/">...</a>is not clickable at point (652, 886). Other element would receive the click: <div class="footer__warning">...</div>
  (Session info: chrome=71.0.3578.80)

有什么想法吗?

编辑:

好像我必须向下滚动到此元素。例如,如果在发出点击事件之前我使用.send_keys(Keys.ARROW_DOWN),则该点击会达到预期的效果。但是,在更确切的情况下,我不知道到底需要滚动多长时间呢?应该是一些搜索脚本吗?

我的意思是我应该如何辨别网站上的错误与错误的测试之间的区别?使用element.location_once_scrolled_into_view滚动到元素是否足够?因为在我的情况下,执行element.location_once_scrolled_into_view之后,我仍然遇到相同的错误,并且只有在进行更多滚动后再进行一点滚动,我才能继续进行测试。

有什么想法吗?

0 个答案:

没有答案