gpt4 book ai didi

selenium - 为什么守夜人找不到我的dom?

转载 作者:行者123 更新时间:2023-12-02 08:16:33 25 4
gpt4 key购买 nike

我正在使用 nightwatch 进行集成测试,但它找不到我的 dom 元素之一。下面是我的 html 代码:

<body>
<div style="position: absolute; overflow: hidden; height: 24px;">
<div class="GPNWDJGEV" style="width: 24px; height: 24px;">
</div>
<div id="gwt-debug-MenuItem" style="width:100px;height:100px;">

</div>
</div>
</body>

下面是守夜人代码。

module.exports = {
'Connection Test' : function (browser) {
browser
.url('file:///tmp/test.html')
.waitForElementVisible("#gwt-debug-MenuItem", 5000)
.pause(1000)
.end();
}
};

运行这个测试用例时出现以下错误:

✖ Timed out while waiting for element <#gwt-debug-MenuItem> to be visible for 5000 milliseconds.  - expected "visible" but got: "not visible"

我能够找到其他 dom 元素,但找不到这个 #gwt-debug-MenuItem。这段代码有什么问题?

最佳答案

看起来该元素并不是真正可见的。尝试使用 waitForElementPresent

等待它的出现
module.exports = {
'Connection Test' : function (browser) {
browser
.url('file:///tmp/test.html')
.waitForElementPresent("#gwt-debug-MenuItem", 5000)
.pause(1000)
.end();
}
};

关于selenium - 为什么守夜人找不到我的dom?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41546915/

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