发送密钥后 Selenium WebElement 值为空
我正在运行一些简单的表单测试,其中值是添加的字段。
将每个值添加到字段后:
input.SendKeys(value);
我想检查字段中的值是否正确。这听起来可能很不寻常,但该字段可能附加了 ajax 搜索,如果搜索没有返回匹配项,则该字段将为空。
我尝试在发送密钥后测试 WebElement 的文本值,但它似乎总是为空:
bool match = input.Text.Equals(value);
// input.Text always seems to be an empty string
我正在将 Selenium 2 与 WebDriver 一起使用 - 是否有另一种方法来执行这些检查?即使 SendKeys 成功将值(实际上在浏览器中)打印到 WebElement(文本框)中,WebElement 仍为空,是否有特殊原因?
任何帮助将不胜感激。
I'm running some simple form tests where values are added fields.
After each value is added to a field:
input.SendKeys(value);
I want to check the value in the field is correct. This may sound unusual but the field may have an ajax search attached and if the search doesn't pull back a match, the field will be empty.
I've tried testing the text value of the WebElement after sending the keys but it always seems to be empty:
bool match = input.Text.Equals(value);
// input.Text always seems to be an empty string
I'm using Selenium 2 with the WebDriver - is there another way to perform these checks? Is there a particular reason why the WebElement is empty even if the SendKeys successfully prints a value (actually in the browser) in to the WebElement (textbox)?
Any help would be grateful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您输入的文本值可能被分配为文本框的“值”属性,而不是“文本”
It may be possible that the text value that you are entering is assigned as a "value" attribute of text box and not as "text"