QTP - 浏览器/页面标题更改时进行测试

发布于 2024-08-18 14:12:49 字数 208 浏览 1 评论 0原文

我试图进行简单的测试,但失败了,因为我不知道如何处理测试期间更改的浏览器标题。

简单的例子: Google>查找“blabol”

完成后,QTP 中的浏览器标题将更名为“Google - 结果......”。当搜索文本是一个在迭代之间变化的变量时,这显然是个问题,因为浏览器文本是硬编码的。 如果您明白我的意思,我需要诸如“此浏览器”和“此页面”之类的内容。 谢谢

I am trying to make simple testing but failed because I have no clue how to handle with browser title that changes during the testing.

Simple example:
Google>Find "blabol"

Once its done, the browser title in QTP changes its name to "Google - results....". This is obviously problem when the search text is a variable that changes between iterations because the browser text is hardcoded.
I would need something like "this browser" and "this page", if you get what I mean.
Thanks

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

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

发布评论

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

评论(2

挽袖吟 2024-08-25 14:12:49

简而言之,您可以使用各种属性来标识 QTP 中的对象,并且可以使用正则表达式来添加更多灵活性。
例如,在您的情况下,解决网络浏览器的可能方法如下。

1) 寻址第一个浏览器窗口(首次打开)和任何页面

Set objBrowser = Browser("creationtime:=0")
Set objPage = objBrowser.Page("title:=.*")

2) 如果您假设您始终使用 Google 页面。

Set objBrowser = Browser("title:=.*Google.*")
Set objGooglePage = objBrowser.Page("title:=.*Google.*") 

3)具有特定搜索结果的地址页面

sSearchWord = "blabol"
boolRC = Browser("title:=" & sSearchWord & " - Google Search.*").Page("title:=" &  sSearchWord & " - Google Search.*")

谢谢,
阿尔伯特·加里耶夫

http://automation-beyond.com/

In a couple of words, you can use a variety of properties for identification of the object in QTP, and you can use Regular Expressions to add even more flexibility.
For example, in your case, possible ways to address web browser would be the following.

1) Addressing first browser window (first opened) and any page

Set objBrowser = Browser("creationtime:=0")
Set objPage = objBrowser.Page("title:=.*")

2) If you assume that you always work with Google page.

Set objBrowser = Browser("title:=.*Google.*")
Set objGooglePage = objBrowser.Page("title:=.*Google.*") 

3) Addressing page with particular search results

sSearchWord = "blabol"
boolRC = Browser("title:=" & sSearchWord & " - Google Search.*").Page("title:=" &  sSearchWord & " - Google Search.*")

Thank you,
Albert Gareev

http://automation-beyond.com/

夜未央樱花落 2024-08-25 14:12:49

这就是为什么 QTP 默认情况下不使用标题作为浏览器描述的一部分。您应该注意,Page 的描述不必严格,因为在任何给定时间,每个 Browser 只有一个 Page(不同的Page的存在只是为了帮助组织对象存储库)。

您可能需要在说明中使用“开放标题” 属性进行检查,因为该属性在导航过程中不会更改。

This is why QTP doesn't by default use the title as part of the description of the Browser. You should note that the description of the Page doesn't have to be strict since there is only one Page per Browser at any given time (different Pages only exist in order to help organize the object repository).

You may want to examine using the "open title" property in the description, since this doesn't change during navigation.

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