English 中文(简体)
QTP - testing while browser/page title changes
原标题:

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

最佳回答

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/

问题回答

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.





相关问题
QTP - testing while browser/page title changes

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 ...

QTP - 取得要素价值

我从QTP开始,仅仅找不到如何获得要素的价值。 例如,当我只想比较一下从山洞中发现的成果数量时。 我试图用物体选择这个要素......

Record enter button in qtp

How to record ENTER button that we use through the keyboard in QTP for applications

How do you write your QTP Tests?

I am experimenting with using QTP for some webapp ui automation testing and I was wondering how people usually write their QTP tests. Do you use the object map, descriptive programming, a combination ...

Dynamically building a URL in QTP

I ve been taking a quick look at QTP with one of our test team. We ve figured out some basics like recording a test, capturing text using output values, putting in check points, etc. However, I can ...

热门标签