简体   繁体   English

Nightwatch.js - 元素存在但不可见

[英]Nightwatch.js - Element present but not visible

I have an element I'd like to check the content of, however, nightwatch isn't recoginsing it, even though it is visible on the screen.我有一个元素我想检查其内容,但是,nightwatch 没有识别它,即使它在屏幕上可见。

  browser.waitForElementPresent('mySelector', 20000) //this succeeds
  browser.waitForElementVisible('mySelector', 20000) //this fails
  browser.verify.containsText('mySelector', 'text') //this also fails (of course)

I checked screenshots at fails, and I can definitely see the html element containing the text I'm looking at, and it works with other similar elements I have.我在失败时检查了屏幕截图,我可以肯定地看到包含我正在查看的文本的 html 元素,并且它可以与我拥有的其他类似元素一起使用。

I'm curious to know what nightwatch itself is looking at when checking for visibility, because I cannot see any hidden attributes in the html element either.我很想知道 nightwatch 在检查可见性时正在查看什么,因为我也看不到 html 元素中的任何隐藏属性。

Problem was with the fact that elements with the same selector stayed in the DOM.问题在于具有相同选择器的元素保留在 DOM 中。 Solved by using nth child.通过使用第 n 个孩子解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM