gpt4 book ai didi

c# - WebDriver - 元素不可点击 Chrome

转载 作者:可可西里 更新时间:2023-11-01 08:37:06 26 4
gpt4 key购买 nike

我有以下问题。我在 Firefox 和 Chrome 上运行测试。在 Firefox 上测试运行正常,但在 Chrome SauceLabs 上给出一条消息:

unknown error: Element is not clickable at point (717, 657). Other
element would receive the click: <div class="col-md-9 col-sm-12"
style="margin-top:8px;">...</div> (Session info: chrome=36.0.1985.125)
(Driver info: chromedriver=2.10.267521,platform=Windows NT 6.3 x86_64)

我在两个测试中以相同的方式通过唯一的 css 选择器选择元素:

driver.FindElement(By.CssSelector("button.btn-xs:nth-child(1)")).Click();

知道这里出了什么问题吗?

最佳答案

我假设您拥有所需的正确元素,即 XPath 是正确的。以下是一些解决方法:

  1. 尝试点击父元素
  2. 尝试使用 .Submit() 而不是 .Click()
  3. 尝试执行将在您尝试单击的元素的 OnClick 事件上执行的 JavaScript

我一直都在使用第三种方式并取得了成功。

另一个

  1. 对该元素(或空格键)执行 .SendKeys(Keys.Enter)

关于c# - WebDriver - 元素不可点击 Chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25929195/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com