Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding Visual Relation id via script to new object
#1
Not Solved
Here is the scenario. I am using a random number to create an email. It will be in a list with a '+' next to it in a grid. All rows will have the '+' and then the email address in line to the right. I need to expand down the '+' to verify that an email was sent to the email address with the random number. Not only do I not know the email address because of the random number, it can be anywhere in the list - first, last, or anything in between. This means I can't rely on index.

My plan - Both of these items are WEBELEMENTS. I want to create the '+' WEBELEMENT and use the email as a Visual Relation identifier in the script.

I can create the object for the email no problem. I am having problems getting the visual relation added to the '+'. I may have been looking at this too long as well so sorry if it is a minor mistake I am overlooking. I need to remember to blink! :-)

Here the script - I set the email for testing:
Code:
Dim sEmail
Dim oDesc        'Description Object
Dim colObject    'Object Collection
sEmail="john214@smith.com"

Set oDesc = Description.Create
oDesc( "micclass" ).value = "WEBELEMENT"
'Additional property- for more focused and controlled collection
oDesc( "Innertext" ).value = sEmail

Set colObject = Browser("title:=MYTITLE").Page("title:=MYTITLE").ChildObjects(oDesc )


Dim oVisualRelation, oRelationToElement, oElementDesc,colobject2
Set oVisualRelation = VisualRelations.Create
Set oRelationToElement = oVisualRelation.Add
oRelationToElement.relatedobjectpath = "Browser(""title:=MYTITLE"").Page(""title:=MYTITLE"").ChildObjects(oDesc )"
oRelationToElement.relativeposition = micRelLeft
oRelationToElement.setargument micRelInline, True

Set ElementDesc = Description.Create
ElementDesc("micclass").Value = "WEBELEMENT"
ElementDesc("visual relations").Value = VisualRelation
Set colobject2 = Browser("title:=MYTITLE").Page("title:=MYTITLE").ChildObjects(ElementDesc)

colobject2(0).Highlight

------------------------------------------------------------------------

Sorry if this is a little simple for this forum. I am stuck and relatively new to QTP. Thanks in advance!

Okay, according to QTP's help files, you can't do this. You must have the object in the object repository to use it as a visual relation identifier.

New plan. Use existing object - add the WEBELEMENT for the email, but update the innertext value. This would make the object on the correct row.

Now, how do I update the object values via the script... back to research. But, any suggestions, please let me know.

Thanks!
Reply
#2
Not Solved
Disclaimer: I understand this is a old thread, but thought that I can post a code snippet so that it can be referred.

In continuation with my another thread (https://www.learnqtp.com/forums/Thread-V...rk-with-DP), I tried to implement the above "new plan", which worked perfect for me. I have used "setTOProperty" to set the property.

Here is the code.
Code:
Dim  desc1, desc2

Set desc1 = Browser("MyBrowser").Page("MyPage").WebElement("Country")
desc1.highlight
desc1.setTOProperty "innertext", "Date of Last Update:"
desc1.highlight


Dim VisualRel, relation
Set VisualRel = VisualRelations.Create

Set relation = VisualRel.Add
relation.RelatedObjectPath = "Browser(""MyBrowser"").Page(""MyPage"").WebElement(""Country"")"
relation.relativeposition = micRelLeft
relation.setargument micRelInline, True
Set relation = 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

NOTE: Care must be taken, as for the rest of the QTP execution session, "Country" object still refers to the "Date of Last Update:" label only. However, after the execution, the local repository is intact, and points to the Country label only.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question adding two conditions into a while statement lotos 4 5,118 11-10-2017, 04:49 AM
Last Post: lotos
  Uft: Adding a property to all ojects into Repository ProTester 0 1,369 06-09-2017, 12:48 AM
Last Post: ProTester
  adding an object to OR seven 1 2,671 02-17-2014, 02:23 PM
Last Post: basanth27
  How to access webtables without adding into Object Repository ramkumarad 7 9,728 12-30-2013, 07:38 PM
Last Post: Sathiya
  Visual Relations does not work with DP ourhari 5 4,738 06-24-2013, 01:04 PM
Last Post: ourhari

Forum Jump:


Users browsing this thread: 2 Guest(s)