Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to identify object once it is moved on the page
#1
Solved: 10 Years, 9 Months ago
Hello,

I have web page where we display different books on the selected topic. Our sales department update this list once a month and post new book on the top. Now I have recorded script last month where I am clicking on first book on first row and then doing some comaprision.

My script FAILES because now First book on first row is changed. My Original book is now in the second row.

How can i idenfity the object once it is moved on the page?

Regards,
Bhavesh
Reply
#2
Solved: 10 Years, 9 Months ago
You can use descriptive programming to identify the books dynamically. search this forum for more help on DP.

Reply
#3
Solved: 10 Years, 9 Months ago
I found the best way was to add the HTML ID property to the object in the repository. Obviously provided it has a tag. This allows you to always find the object anywhere on the page provided the id is unique. I sometimes had to add it manually by doing a "view source" on the page. This can be tricky if it's a .NET web page, but so far with a little effort, I've been pretty successful at making it work.
Reply
#4
Solved: 10 Years, 9 Months ago
How to add HTML ID Property in the OR?
Reply
#5
Solved: 10 Years, 9 Months ago
In the repository, select the object. On the right you should see the object properties area. In that area is a green +. click that and you will get a properties dialog popup. Depending on the class of object, you will see properties you can add. HTML ID should be one of them if it s a properly identified web object. There might be other tags you can use in there if ID isn't available. Be careful with X,Y as your control is moving around.
Reply
#6
Solved: 10 Years, 9 Months ago
That is fine. so what can i do after finding the HTML Id? I have to use DP to find the ID and then click on that link so that If link (Object) is moved then I will ok?

Thanks,
Bhavesh
Reply
#7
Solved: 10 Years, 9 Months ago
Yep. Just call the object with the action....

Browser(something).Page(page).object(name).whatever.

All the HTML id will do is allow you to find the object on the page. It's a unique identifier for the object.

you can now iterate throught the rows and cell once the tableobject is uniquely identified like so:

Code:
For x =2 to Browser(browserobject).Page(pageobject).WebTable(tableobject).RowCount
y = y + cdbl(trim(replace(Browser("browserobject").Page("pageobject").WebTable("tableobject").GetCellData(x, 4),"$","")))
next

This example would sum dollar amounts in each row column 4
Reply
#8
Solved: 10 Years, 9 Months ago
In case the books is inside the web table. Here is what you can do to make your script generic:

  1. Get the total number of rows of a web table.
  2. Using conditional statements (comparing every cell name with the book name) narrow down the cell.
  3. Now using WebTable().ChildItem property click on the book name.
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#9
Solved: 10 Years, 9 Months ago
yep.

You can also use the GetRowWithCellText()

like....

Code:
x=  Browser("MSN").Page("MSN").WebTable("LinkTable").GetRowWithCellText("CNN",1)
Browser("MSN").Page("MSN").WebTable("LinkTable").ChildItem(x,1,"Link",0).Click

This code would look for "CNN" in column 1, then click the link in the row.
Reply
#10
Solved: 10 Years, 9 Months ago
Yes, that will also work but make sure that there is no other entry in the web table that starts with the same name. I have made a post on this topic earlier in one of the threads on How to record the double click actions?
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to identify an error page occurring in server in between the qtp run. aswini 1 1,639 05-04-2017, 03:52 PM
Last Post: Ankur
  Cannot identify the object "Webtable" korunu 1 2,390 06-29-2016, 05:28 PM
Last Post: Ankesh
  Cannot identify the object "Webtable" korunu 0 1,637 05-11-2016, 12:02 AM
Last Post: korunu
  QTP "Cannot identify the object" richardpaulhall_2 3 13,322 08-20-2015, 11:46 PM
Last Post: ADITI1992
  What is the criteria of identify the object based on Base & option filter properties Suma Parimal 2 2,890 01-28-2014, 06:35 PM
Last Post: Suma Parimal

Forum Jump:


Users browsing this thread: 1 Guest(s)