QTP-在浏览器/页面标题更改时进行测试 [英] QTP - testing while browser/page title changes

查看:103
本文介绍了QTP-在浏览器/页面标题更改时进行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试进行简单的测试,但是失败了,因为我不知道如何处理在测试过程中更改的浏览器标题.

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.

简单的例子: Google>找到"blabol"

Simple example: Google>Find "blabol"

完成后,QTP中的浏览器标题将其名称更改为"Google-results ....".当搜索文本是在迭代之间更改的变量时,这显然是问题,因为浏览器文本是硬编码的. 如果您理解我的意思,我将需要诸如此浏览器"和此页面"之类的东西. 谢谢

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

推荐答案

简而言之,您可以使用各种属性来标识QTP中的对象,还可以使用正则表达式来增加灵活性. 例如,根据您的情况,以下是解决Web浏览器的可能方法.

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)寻址第一个浏览器窗口(首先打开)和任何页面

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

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

2)如果您始终使用Google网页.

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

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

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

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/

这篇关于QTP-在浏览器/页面标题更改时进行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆