如果网页上出现特定元素,有没有办法让 QTP 测试失败

发布于 2024-10-08 05:42:17 字数 207 浏览 0 评论 0原文

我正在尝试使用 QTP 测试基于 JSP 的 Web 应用程序。在某些页面上,JSP 被编码为向浏览器返回特定的 div 元素,该元素将具有 ID 属性,只有底层模型设置了特定的布尔标志。我希望能够开发一个 QTP 测试,如果 div 出现在返回的网页中,该测试就会失败。然而,QTP 文档似乎没有任何关于如何执行此操作的详细信息。

I am trying to test a JSP based web application with QTP. On some of the pages the JSP is coded to return a particular div element, which will have an ID attribute, to the browser, only of the underlying model has a certain boolean flag set. I'd like to be able to develop a QTP test that fails if the div is present in the returned web page. However, the QTP documentation doesn't seem to have any details on how to do this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

祁梦 2024-10-15 05:42:17

重点是检测条件是否适用,然后显式地使测试失败。

If Browser("b").Page("p").WebElement("html tag:=div", "html id:=theId").Exist Then
    ''# Report failure 
    Reporter.ReportEvent micFail, "Element Exists", "It shouldn't"
    ''# if you also want to stop the test
    ExitTest
End If

The point is to detect if the condition applies and then explicitly fail the test.

If Browser("b").Page("p").WebElement("html tag:=div", "html id:=theId").Exist Then
    ''# Report failure 
    Reporter.ReportEvent micFail, "Element Exists", "It shouldn't"
    ''# if you also want to stop the test
    ExitTest
End If
神爱温柔 2024-10-15 05:42:17

QTP 的默认行为是在检查点失败时写入“报告”。即如果在页面上找不到某个元素,QTP 将自动写入日志报告中。为了禁用该功能,并根据您的测试场景自定义您的报告,您可以从
仅在发现异常行为时才开始写。

报告者.Filter = rfDisableAll
'检查点验​​证
报告者.Filter = rfEnableAll

The default behavior for QTP is to write in 'Report' when a check point fails. i.e. if an element is not found on the page , automatically the QTP will write in the log report. In order to disable that , and to customize your report depending on your test scenarios, you can disable the report logging from the
beginning and write only in case you found an abnormal behavior.

Reporter.Filter = rfDisableAll
'check point validations
Reporter.Filter = rfEnableAll

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文