This has been tested to work correctly on QTP versions: 9.5+.
There is a common perception that we must include the Browser object in hierarchies when working in the Web environment. The truth is that, we really don’t need to include the Browser object if the Page object has been included in the hierarchy.
In other words, the commonly written inline statements for Web environment:
Browser("title:=Google").Page("title:=Google").WebEdit("name:=q").Set "Test" Browser("title:=Google").WebEdit("name:=q").Set "Test"
can also be written like this:
Page("title:=Google").WebEdit("name:=q").Set "Test"
Quick tip! Thanks for visiting Relevant Codes! :)
{ 30 comments… read them below or add one }
Hi ,
I need ur help I am going to attend for first time testing interview I nedd some good interview questions manual and automation and QTP.
Could you please provide me suggestion and give some real time senarios what are the questions they in QTP.
Please do the needfull regarding this.
Satish,
I really hope your interview goes well!
I’m sorry, but this is an area where my advise can prove to be more harmful than helpful. The interviewer can ask anything depending upon their environment, technologies and release schedules.
Page(“title:=Google”).WebEdit(“name:=q”).Set “Test”
If I use this statement I got a error message as,
Cannot find the “[ WebEdit ]” object’s parent “[ Page ]” (class Page). Verify that parent properties match an object currently displayed in your application.
Do you I need to do any settings?
Hi Harish,
The above code is working fine for me.. Can you make sure you do not have more than 1 browser with the same properties open?
Harish, any luck having this work on version 9.2? I have included a small note in this post regarding version compatibility.
Hi, Anshoo,
I remember I can write as this
Browser("title:=Google").WebEdit("name:=q").Set "Test"I suppose your perception can working well, so why the “Page(“title:=Google”)” is required?
Can I understand it as we need to indicate at least one specific container for the web element? So we can write as
Browser("title:=Google").WebEdit("name:=q").Set "Test"and also
Page("title:=Google").WebEdit("name:=q").Set "Test"Am I right?
Regards,
Dennis
Absolutely :)
There is one thing though. When using ChildObjects, you must include the Page object otherwise the count will be incorrect. In other words:
Set oDesc = Description.Create 'Will give 1 because it has only one childobject, which is the Page object MsgBox Browser("title:=Find.*").ChildObjects(oDesc).Count MsgBox Page("title:=Find.*").ChildObjects(oDesc).CountHi , i want the qtp scripts for below scenarios,plz do needfull
1.I have two buttons which are rotating in clockwise direction in page . i need qtp script two click on second button.
2. i have a weblist where i can select multiple items using Ctrl , i need qtp script to select any four items among the available 10 items.
Hi Shekhar,
1. If these are the same buttons with the exact same properties, then regardless of their movement on the screen, you can use the Index/Location identifiers to distinguish between them. The first button will be Index 0, the second one will be Index 1. Example:
'Button 1 .WebButton("name:=Button", "index:=0").Click 'Button 2 .WebButton("name:=Button", "index:=1").Click2. You can use the
ExtendSelectmethod to perform this.Hi Anshoo,
I was stuck up in choosing the correct automation tool for automating web based application (developed using Flash components). QTP recognizes the whole window as a single object, instead of individuals (where some internal components also reside in it). Is there any way(by exposing any API’s or so to the source) where we can make the QTP to recognize such objects…
Else can you please suggest me the best automation tool which can solve my problem (Automating the customized flash components…)
Regards,
Venkat…
Hi Venkat,
I haven’t had much experience automating Flex/Flash applications but I do know that there are some limitations with this. Please see this article: http://livedocs.adobe.com/flex/3/testing_with_QTP_flex3.pdf
It does cover some of the limitations.. Not sure what the best automation tool would be though. :(
Hi Anshoo,
Thanks a lot for your quick reply, and thanks a lot for sharing your experience with us thru this blog and this blog is very usefull to guys like me.Gr8 work , i wish and hope to continue the same.
and i have one more question in my mind,
i have a webtable like below.
AccountNo AccName Balance
100 shekhar 10000
A100 Chandra 2000
100a Guttikonda 500
A100a Chandrashe 5000
Now my query is i want to get the rowcount whose accountno starts with 100.By phiscally seeing the row count 2 and i want to get the same rowcount with qtp script
Shekhar,
You can use the
GetCellDatamethod of the WebTable to retrieve cell values. Example:iRows = Browser("").Page("").WebTable("").GetROProperty("rows") iCols = Browser("").Page("").WebTable("").GetROProperty("cols") For ix = 1 to iRows For iy = 1 to iCols If Browser("").Page("").WebTable("").GetCellData(ix, iy) = 100 Print "Data found on Row: " & ix & " and Column: " & iy End If Next NextI was stuck up in choosing the correct automation tool for automating web based application (developed using Flash components). QTP recognizes the whole window as a single object, instead of individuals (where some internal components also reside in it). Is there any way(by exposing any API’s or so to the source) where we can make the QTP to recognize such objects…
Else can you please suggest me the best automation tool which can solve my problem (Automating the customized flash components…)
Regards,
Venkat
For testing a flash/flex application you need flex addin and your flex application has to be compiled with automation library or call the application in html wrapper. here is the doc which tells you how to do installation http://www.adobe.com/support/documentation/en/flex/2/install.html
Let me know if you need more info….
-Vasanth
Thanks a lot Vasanth.. I will go through the links you have provided..will get back to you if I fins any obstacles in my path…Thanks a lot once againnnnn
hello vasanth,
with referance to your post I can understand that qtp supports flex. However, I would like to make sure that whether qtp suppors flash or not.
Thats a fantastic article Anshoo.. I really like your website.
Jenny
Hi Anshoo,
I am facing a problem. I am automating a web application. I am using set of properties to identify the object. But for each build the property values are changing. Development team is not ready to keep the fixed standard property values as per the requirement.
How can I handle these scenarios.
Generally, I try to educate my clients to not start automating on a grand scale until the application has reached a point of stability. Its always a nightmare to automate applications that are constantly changing, or are in constant development that either impact the test fields or the business process.
There are however dynamic applications, which are generally a challenge to automate but there are numerous ways to handle such scenarios. However, yours being the former case, I’m afraid you will face some maintenance issues every now and then because tests are generally basic on the application’s flow and any change to that causes tests to fail.
Hi Anshu,
Why it is possible for the QTP to skip the Browser/Page object in web inline statement? Is it that they are not mandatory for each other in the web test objects?
regards
Niranjan
Hai Anshoo,
Your mind goes brilliant in QTP
I am a Great Fan of yours………
I want to tell you one Thing
I am your permanent Member of relevant codes……
“Bus Yuhi Chalte Rehna…”
hi anhoo please tell me i have one doubt if we want to check whether the web paage has all the contents or not i..e if any web page has only checkboxes then we have to check all the checkboxes are available or not we dont know how many are there please tell me
Kumar: This can be done through ChildObjects. Please see here: http://relevantcodes.com/qtp-all-about-the-description-object-description-create/
hi thanks a lot for your response currently iam handling a new project with .Net windows environment can we follow the same process please guide me & give me some basics related to that thank you
I guess this works only with the DP. with normal OR approach its of no use..
Any ways good post.. :)
Anshoo,
Another Gem of an article.. I wonder how you get to know all these things.. :) But i guess Browser object would help in organizing the repository in case we have to deal with multiple browsers/pages. What’s your thought on this?
@Shailesh,
I have tried to use the same logic in OR also. It works perfectly fine.. :)
Just want to say here that in case you’re using .ChildObjects here, remember to add a Page object. ChildObjects will return 0 if Page is not added.
Thanks a lot Anshooo
Hi Anshoo,
Thanks for the code..
But the code ur suggesting is ..that everycell value is equating to 100.
but i need the count of the rows whose account is starting with 100.
how can achive it.
You will have to change that code and use InStr instead then..