WebAii - 在网页输入框中输入文本时面临的问题
执行的步骤
1. 打开需要以编程方式输入数据的网页
2.通过传递元素Id获取Element实例。
3. 通过传递 element 和 textToSet 来调用 ArtOfTest.WebAii.TestTemplates.BaseTest 类中 Actions 实例中的 SetText 函数
预期的解决方案
始终需要在文本框中输入文本。
实际产量
文本并不总是输入到文本框中。有时输入正确,有时跳过而不输入值。调试时,观察到元素实例被正确检索,并且调用 SetText 函数并且没有抛出异常。当未输入值时,在函数顶部再次设置控件并再次运行将在文本框中设置值。
谁能告诉我这种奇怪行为的原因吗? 如果需要更多详细信息,请告诉我。
Steps performed
1. Open a web page where data needs to be entered programmatically
2. Retrieved Element instance by passing element Id.
3. Call SetText function in Actions instance in ArtOfTest.WebAii.TestTemplates.BaseTest class by passing element and textToSet
Expected solution
Text need to be entered in the text box always.
Actual Output
Text is not always entered in the text box. Some times entering correctly and sometimes skipping it without entering the value. When debugging, observed that, the element instance is retrieved properly and SetText function is called and no exceptions are thrown. When the value is not entered, setting the control again at the top of the function and running it again will set the value in the text box.
Can any one tell me the reason for this weird behaviour?
Please let me know if more details are required.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的描述听起来像是一个时间问题。由于测试脚本通常运行速度非常快,因此它们很容易超过您的 Web 应用程序。如果您的测试在调试时运行(即缓慢运行或单步运行),但在全速运行时间歇性失败,则几乎肯定会遇到计时问题。当您的测试脚本尝试将数据输入到 Web 应用程序时,您的 Web 应用程序可能还没有准备好接受文本输入,如果您的 Web 应用程序正在进行 AJAX 回发,这是一个非常常见的问题。解决此类问题的最简单方法是在 SetText 调用之前添加固定延迟。更高级的技术是监视 Web 应用程序中包含的某些属性或元素,以检测其何时准备好输入并等待设置。正确设置该属性后,调用 SetText 函数。
科迪
Telerik 技术支持团队
Your description sounds like a timing problem. Since test scripts usually run very quickly it is easy for them to outrun your web application. If your test runs while debugging it (i.e. running slowly or single stepping) but intermittently fails when run at full speed, you are almost certainly running into a timing problem. Your web application may not be ready to accept text input at the time your test script is trying to feed the data into it, which is a very common problem if your web application is doing an AJAX postback. The easiest method to overcome such a problem is to add a fixed delay just before the SetText call. A more advanced technique is to monitor some property or element contained within your web application to detect when it's ready for input and wait for that to be set. Once that property is correctly set then call the SetText function.
Cody
Telerik Technical Support Team