waitfortext不工作以找到文本,而是waituntil作品
我准备将头发拉出。不确定我在做什么错,但这是问题:
我有一个文本框,我正在为此验证错误消息。 HTML看起来像这样:
<span class="text-field-error" data-valmsg-for="Name" data-valmsg-replace="true"><span id="Name-error" class="">There are invalid characters being used.</span></span>
我的XPATH查找错误消息看起来像这样:
//span[@id='Name-error']
我使用以下命令来验证错误消息:
driver.waitForText('//span[@id='Name-error']','There are invalid characters being used.')
此验证失败。
但是,当我尝试以下命令时,它可以正常工作。
driver.waitUntil('//span[@id='Name-error']',"_.innerText.includes('There are invalid characters being used.')")
我已经验证了一开始没有隐藏的空格。我必须使用Waitfortext vs Waituntil来跟上项目中的编码标准。
请建议,彼得。
I am getting ready to pull my hair out. Not sure what I am doing wrong but here is the issue:
I have a textbox for which I am verifying an error message for. The html looks something like this:
<span class="text-field-error" data-valmsg-for="Name" data-valmsg-replace="true"><span id="Name-error" class="">There are invalid characters being used.</span></span>
My xpath to locate the error message looks something like this:
//span[@id='Name-error']
I am using the following command to verify the error message:
driver.waitForText('//span[@id='Name-error']','There are invalid characters being used.')
This verification fails.
However, when I try the following command, it works fine.
driver.waitUntil('//span[@id='Name-error']',"_.innerText.includes('There are invalid characters being used.')")
I have verified there is no hidden whitespace in the first instance. I have to use waitForText vs waitUntil to keep up with coding standards within my project.
Please advise, Peter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道,也许这是一个错误。如果您可以提供复制的方法,那将有助于社区: https ://github.com/karatelabs/karate/tree/develop/examples/ui-test
同时,看看这是否有效:
我不禁注意到您在需要时不使用双引号。
I have no idea, maybe it is a bug. If you can provide a way to replicate, that will help the community: https://github.com/karatelabs/karate/tree/develop/examples/ui-test
Meanwhile see if this works:
I can't help noticing that you are not using double-quotes when needed.