单击在 selenium 和 nightwatch 中不起作用

raf*_*lle 2 jquery selenium

我对 nightwatch 有这个问题,其中 .click() 不能与选择器一起使用。我添加了 --verbose 参数,它显示了这条消息“在 (525, 560) 点不可点击”。它适用于常规 jquery 执行,但我需要它来处理 nightWatch 命令和 selenium。

我创建了一个自定义命令来单击,其中包括在单击之前查看对象是否可见的验证。我在下面添加了这个函数,以及来自 --verbose 参数的完整错误。

module.exports.command = function(source) {
  let self = this

    self
  .waitForElementVisible(source,6000)

  .click(source)

  return self
}
Run Code Online (Sandbox Code Playgroud)

值:{消息:'未知错误:元素......在点(525、560)处不可点击。其他元素会收到点击:...\n (Session info: chrome=61.0.3163.100)\n (Driver info: chromedriver=2.33.506092 (733a02544d189eeb751fe0d7ddca79a0ee28cce4),platform=Linux)-4.4.64.generic } }

Pab*_*ios 5

为了避免 selenium 的错误,您必须将指针移动或悬停到该位置,您可以使用 .moveToElement 来做到这一点。

您还可以在文档nightwatch-docs 中看到它的用法。

只是为了澄清这不是真正的守夜错误,而是硒错误。

module.exports.command = function(source) {
  let self = this

    self
  .waitForElementVisible(source,6000)
  .moveToElement(source,undefined, undefined)
  .click(source)

  return self
}
Run Code Online (Sandbox Code Playgroud)