0% found this document useful (0 votes)
45 views4 pages

QTP Problem and Its Solution

This document discusses solutions for identifying a web element in QTP when the element's properties are changing dynamically. It recommends finding a unique combination of properties, nesting the element under another identifiable container, using visual relations identification, or adding an ordinal identifier. For retrieving changing values from a web element, it suggests including additional identifying properties, updating the object repository, using a description to find matching elements, or extracting the value from a surrounding table.

Uploaded by

Karthi Nagarajan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views4 pages

QTP Problem and Its Solution

This document discusses solutions for identifying a web element in QTP when the element's properties are changing dynamically. It recommends finding a unique combination of properties, nesting the element under another identifiable container, using visual relations identification, or adding an ordinal identifier. For retrieving changing values from a web element, it suggests including additional identifying properties, updating the object repository, using a description to find matching elements, or extracting the value from a surrounding table.

Uploaded by

Karthi Nagarajan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

QTP Problem and its Solution

1) I would like to get information about a web-element. This web-element is always present on the page. But QTP
can't recognize, because there is a lot of web-elements with the same class. By default QTP used to recognize this
web-element by it's InnerText property, but in the last build InnerText became changing dynamically. And
number of the web-elements of the required class is changing from build to build. Do you know, how could I help
QTP recognize this object? I've tried to add x and y absolute and relative coordinates, but it didn't work.
Identifying elements by location is very brittle and should be avoided when possible.
Your question does not contain enough information in order to give a specific answer but here is how one achieves objects
identification in the general case:
You have to find a combination of properties that make the description unique and robust. If this is hard to do you can use
the following advanced object identification techniques.
1. By default QTP has all web elements nested directly under the Page or Frame, but you can nest an object under any
other web element. If your element is contained within another element which you can identify drag and drop it in the
object repository under said container and then the description only has to be unique in regards to the container's other
descendant elements
2. Assuming you're using QTP 11 (or later) you can use visual relations identification. This can be very helpful in
identifying objects (see documentation for more information).
3. If all else fails you can use an ordinal identifier, if 3 elements match the description and the element you're looking for is
always the second you can add this information in the ordinal identifier section of the object repository.

2 .Retriving value from Webelement in QTP

Today i got a problem from one of my reader regarding "Retriving value from Webelement in QTP"...
I have a question to you regarding an issue we faced today.


Scenerio is:-

1)We have an object as WebElement whose value is dynamically changing.For example,say i want to retrieve a policy
number.When i added that object and retrieve with GETROPROPERTY,it is retrieving only one value which is added in the
OR.For the next iteration it is throwing an error saying cannot find object.

In this scenerio, we use regular expression,but using that it didnt helped.What are the other way to solve this issue?Please
help me regarding this.
well..
If the value of the webelement changes then getRoProperty sometimes do not work ...
As you are capturing policy number. So i assume that it changes from policy to policy.
I dont know your application. I am assuming it is on Web and written on any of the web language.
I am taking an example of Gmail home page where the third space "Lots of space" is getting changed time to time.


So if you add this and try to use the function getROProperty ,then the problem you will face is like this only...


The alternative approaches are:

1.Please try to include additional properties inorder to make the webelement get identified as they could have added extra
properties.Spy the object get the porperties for the extra properties
2.You can update the webelement from the application into the object repository and make sure class of the object is not
changed.







Browser("Google").Page("Google").Sync

Browser("Google").Navigate http://www.google.co.in/
Browser("Google").Page("Google").Link("Gmail").Click


msgbox Browser("Google").Page("Gmail: Email from Google").WebElement("place").GetROProperty("innertext")









3. if the above approah does not give you the required result please try this...

Code:
Set childobjdes = Description.Create()

childobjdes("micclass").value="WebElement"
childobjdes("innerhtml").value=".*[A-Za-z0-9].*"
childobjdes("outertext").value =".*[A-Za-z0-9].*"
Set oWebElement = Browser("Google").Page("Gmail: Email from Google")
Set oStyle = oWebElement.Childobjects(childobjdes)
msgbox oStyle.count
For i=o to oStyle.count-1
msgbox i &"->" & oStyle(i).getROProperty("outertext")
Next


So you can exactly get the Element no and track your required no.

4. If all the above code does not give you the required result then you can actually go for this concept.
If you really see the webpage...this is a table structure. even QTP identifies those tables...the values of this space or policy
number (for your case) is coming to cell of a table.

Now you need to add these tables to your OR. atleast the last table..
Code:
r= Browser("Gmail: Email from Google").Page("Gmail: Email from Google_2").WebTable("Less spamKeep
unwanted").RowCount

c= Browser("Gmail: Email from Google").Page("Gmail: Email from Google_2").WebTable("Less spamKeep
unwanted").ColumnCount(r)
For i=1 to r
For j=1 to c
msgbox Browser("Gmail: Email from Google").Page("Gmail: Email from Google_2").WebTable("Less spamKeep
unwanted").GetCellData(i,j)
Next
Next


From the string you can find the policy number.

Hope this will help you.
Let me know if you need any other help.

You might also like