Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Visual Relations does not work with DP
#1
Solved: 11 Years, 5 Months, 4 Weeks ago
Hi experts,

I'm new to QTP DP and I'm having issues in object identification using Visual Relations. However the same is working fine with establishing relationship in OR.

Please see the attached image. There is a "Date of Last Update:" label, followed by a date as label. These two labels are available in TD elements of a HTML table.

With the below code, I'm expecting to locate the actual date value in the page (i.e., extract last update date from the page for further processing). However, I'm getting the below code.

==================== ERROR MESSAGE ================
Cannot identify the object "[ WebElement ]" (of class WebElement). Verify that this object's properties match an object currently displayed in your application.

Line (41): "Browser("title:=.*").Page("title:=.*").WebElement( desc2).highlight".

Tip: If the objects in your application have changed, the Maintenance Run Mode can
help you identify and update your steps and/or the objects in your repository.
=================================================

Line 41 is the last line in the below code snippet. Until this line, I'm getting the results as expected; i.e., the table cells are properly highlighted.

Code:
Dim desc1, desc2, desc3

Set desc1 =  Description.Create
desc1( "innertext").Value = "Date of Last Update:"
desc1("html tag").value= "TD"

Set desc3 =  Description.Create
desc3( "innertext").Value = "Updated By:"
desc3("html tag").value= "TD"

Browser("title:=.*").Page("title:=.*").WebElement(desc1).highlight
Browser("title:=.*").Page("title:=.*").WebElement(desc3).highlight


Dim VisualRel, relation, relation1

Set VisualRel = VisualRelations.Create

Set relation = VisualRel.Add
relation.RelatedObjectPath = "Browser(""title:=.*"").Page(""title:=.*"").WebElement(desc1)"
relation.relativeposition = micRelLeft
relation.setargument micRelInline, True
Set relation = Nothing


Set relation1 = VisualRel.Add
relation1.relatedobjectpath = "Browser(""title:=.*"").Page(""title:=.*"").WebElement(desc3)"
relation1.relativeposition = micRelRight
relation1.setargument micRelInline, False
Set relation1 = Nothing


Set desc2 =  Description.Create
desc2("innertext").Value = ".*"
desc2("html tag").value= "TD"
desc2("Visual Relations").Value = VisualRel

Browser("title:=.*").Page("title:=.*").WebElement( desc2).highlight

Even if I have removed the "relation1", I'm still getting the same error.

I have also tried to provide the below to the RelatedObjectPath property of relation & relation1 objects.

Existing:
Code:
relation.RelatedObjectPath = "Browser(""title:=.*"").Page(""title:=.*"").WebElement(desc1)"
New:
Code:
relation.RelatedObjectPath = "Browser(""title:=.*"").Page(""title:=.*"").WebElement(""innertext:=Date of Last Update:"", ""html tag:=TD"")"

... but still I'm getting the same error.

Could any one please review and let me know what mistake I made that prevented me getting the expected behaviour?

As a side node: Is this the right approach to extract data using DP? Or are there any other methods that can be used?

Many thanks in advance.

Regards,
Hari


Attached Files Image(s)
   
Reply
#2
Solved: 11 Years, 5 Months, 4 Weeks ago
Hari, Welcome to QTP forums.

Why are you using Visual Relation identifiers? Did you try the normal approach first by Object spying on the date?
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#3
Solved: 11 Years, 5 Months, 4 Weeks ago
(06-23-2013, 09:10 PM)Ankur Wrote: Hari, Welcome to QTP forums.

Why are you using Visual Relation identifiers? Did you try the normal approach first by Object spying on the date?

Please find below the identification properties taken from Object Spy.
"Class Name:=WebElement",
"abs_x:=449",
"abs_y:=758",
"class:=",
"height:=16",
"html id:=",
"html tag:=TD",
"innerhtml:=14-May-2013 ",
"innertext:=14-May-2013 ",
"outerhtml:=<TD vAlign=top align=left>14-May-2013 </TD>",
"outertext:=14-May-2013 ",
"type:=",
"visible:=True",
"width:=510",
"x:=346",
"y:=538"

I have written the below code to identify the object and it is successful.
Code:
Set desc2 =  Description.Create
desc2( "innertext").Value = "14-May-2013"
desc2("html tag").value= "TD"

Browser("title:=.*").Page("title:=.*").WebElement( desc2).highlight

However, the page contains many such date values and I want to identify only the date value after 'Date of Last Update:' text.

Please review and advise.
Reply
#4
Solved: 11 Years, 5 Months, 4 Weeks ago
Okay even in case of multiple dates being on the same page here is what I can advise -

  1. Make a collection of all dates appearing on the page. You can use regular expression for date while creating a Description object.
  2. In that collection, YOUR date must be at some position. Run the script to check that position and extract the contents.
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#5
Solved: 11 Years, 5 Months, 4 Weeks ago
@Ankur, Thanks for the alternate solution. I understand that it will definitely work in a static page; where there are fixed number of such date text values.

However, I would like to understand what is wrong with the Visual Relations and why it did not work. I guess that I made some trivial mistake, but do not know how to spot it. Any help would be greatly appreciated.

Thanks again.
Reply
#6
Solved: 11 Years, 5 Months, 4 Weeks ago
On searching the net for solutions, I came across a post (www.knowledgeinbox.com), where I confirmed with @Tarun that Visual Relations work with OR objects only.

http://knowledgeinbox.com/forums/uft-qtp...identifer/

I created an OR object and used it in the Visual Relations as given below and it is identifying the object as expected.

Code:
relation.RelatedObjectPath = "Browser(""MyBrowser"").Page(""MyPage"").WebElement(""LastUpdatedDateLabel"")"

Therefore, it has to be a blend of OR and DP when it comes to Visual Relations.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Adding Visual Relation id via script to new object jcraig26 1 4,123 06-24-2013, 01:26 PM
Last Post: ourhari
  Adding a Visual ID - creating a function jcraig26 0 2,584 11-09-2012, 02:56 AM
Last Post: jcraig26
Question Achieving Visual Relation Identifier option using AOM scsvel 1 5,212 02-17-2012, 04:17 PM
Last Post: scsvel
  Problem with IE - Visual C++ library error sumalatha 0 1,806 06-16-2009, 10:57 AM
Last Post: sumalatha
  Cannot detect other layer of visual tree qtpnewbee 1 2,242 07-18-2008, 07:57 PM
Last Post: vamshiram

Forum Jump:


Users browsing this thread: 2 Guest(s)