Question

i am using visual relation Identifier in QTP for setting a value in webedit.Here is my code

Set rc = VisualRelations.Create
Set relation = rc.Add 
relation.relatedobjectpath = "Browser(""ABC"").Page(""XYZ"").WebElement(""innertext:=E-Mail ID"")"
relation.relativeposition = micRelLeft
relation.setargument micrelinline, True
Set des=Description.Create
des.Add "micclass","WebEdit"
des.Add "visual relations",rc
Browser("ABC").Page("XYZ").WebEdit(des).set "qtpuser@abc.com"
Set relation = Nothing
Set rc = Nothing

The problem is when i use description programming for webElement in Line 3 the QTP showing an error message "Cannot find "webedit" objects parent". But, when i store webelement "E-Mail id" in OR, the code is working fine without any error.

Can u please tell me what can i do in this case to resolve the issue. Thanks in Advance:)

Was it helpful?

Solution

There seems to be a limitation in QTP that the anchor test object in VRI must be in the object repository.

Thankfully there is a workaround, you can create a dummy anchor test object in the OR with a description of a blank innertext (by using the Define New Test Object button).

Screen shot of object repository

Then use SetTOProperty to get the dynamic behaviour you can achieve with descriptive programming.

Set rc = VisualRelations.Create
Set relation = rc.Add 
Browser("ABC").Page("XYZ").WebElement("Anchor").SetTOProperty "innertext", "E-Mail ID"
relation.relatedobjectpath = "Browser(""ABC"").Page(""XYZ"").WebElement(""Anchor"")"
relation.relativeposition = micRelLeft
relation.setargument micrelinline, True
Set des=Description.Create
des.Add "micclass","WebEdit"
des.Add "visual relations",rc
Browser("ABC").Page("XYZ").WebEdit(des).set "qtpuser@abc.com"
Set relation = Nothing
Set rc = Nothing

OTHER TIPS

When you store the WebElement "E-Mail id" in OR, its parent Page(""XYZ"") will also be stored into OR. The problem is that OR way is used to identify Page, but the DP way is used to identify the WebElement. If you delete the WebElement "E-Mail id" but remain the Page("XYZ"), the script should work well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top