QTP General Run Error for webElement GetROProperty (1333 Views)
Reply
Occasional Advisor
sidhanson
Posts: 10
Registered: ‎09-02-2009
Message 1 of 6 (1,333 Views)

QTP General Run Error for webElement GetROProperty

Hi All,
I am getting :

General run error.
Line (49): "msgbox cElements(i).GetROProperty("innertext")".

For the following code:

Set myBrowser=Description.Create()
myBrowser("micclass").Value="Browser"

Set myPage=Description.Create()
myPage("micclass").Value="Page"

Set wElement=Description.Create()
wElement("micclass").Value="WebElement"

Set cElements=Browser(myBrowser).Page(myPage).ChildObjects(wElement)
ElementsCount=cElements.count()
For i=0 to ElementsCount-1
msgbox cElements(i).GetROProperty("innertext")
If cElements(i).GetROProperty("innertext") = elementName Then
myY = cElements(i).GetROProperty("y")
Exit for
End If
Next

Any idea what I am doing wrong?
Thanks.
Please use plain text.
Honored Contributor
Rhonda Robinson
Posts: 3,159
Registered: ‎11-13-2007
Message 2 of 6 (1,333 Views)

Re: QTP General Run Error for webElement GetROProperty

So is cElements an array containing the names of all the child objects on the page? Then you are reading the values from the array in your For loop?

So if one of your chilc objects is a "Cancel" button -
Then your msgbox command would read like:
msgbox cElement(Cancel).GetROProperty(Innertext")

I don't think that will work. You may need to assign a variable to the GetROProperty command, and then display the value of the variable in the msgbox command.

Try something like:
myVar = cElements(i).GetROProperty("innertext")
msgbox myVar

Please use plain text.
Honored Contributor
Sperk
Posts: 933
Registered: ‎04-22-2009
Message 3 of 6 (1,333 Views)

Re: QTP General Run Error for webElement GetROProperty

Rhonda they should all be WebElements looking at his code.

Mark Smith.
Please use plain text.
Honored Contributor
Sperk
Posts: 933
Registered: ‎04-22-2009
Message 4 of 6 (1,333 Views)

Re: QTP General Run Error for webElement GetROProperty

I think it's failing because of the kind of WebElement it is.

WebElement is a bit of a catch-all for undefined specific objects, some of the intitial WebElements may represent objects that cannot be interrogated like this.

I ran this code against this page and it seemed to backup my thoughts:


Set myBrowser=Description.Create()
myBrowser("micclass").Value="Browser"

Set myPage=Description.Create()
myPage("micclass").Value="Page"

Set wElement=Description.Create()
wElement("micclass").Value="WebElement"

Set cElements=Browser(myBrowser).Page(myPage).ChildObjects(wElement)

MsgBox cElements(111).GetROProperty("innertext")
MsgBox cElements(222).GetROProperty("innertext")
MsgBox cElements(333).GetROProperty("innertext")
MsgBox cElements(444).GetROProperty("innertext")
MsgBox cElements(555).GetROProperty("innertext")
MsgBox cElements(1).GetROProperty("innertext")


Mark Smith.
Please use plain text.
Respected Contributor
Erodabasi Atacan
Posts: 588
Registered: ‎01-16-2008
Message 5 of 6 (1,333 Views)

Re: QTP General Run Error for webElement GetROProperty

Try for example
For Each Element In cElements
...
Next

an specify elementName
Please use plain text.
Occasional Advisor
sidhanson
Posts: 10
Registered: ‎09-02-2009
Message 6 of 6 (1,333 Views)

Re: QTP General Run Error for webElement GetROProperty

Thanks Mark,
You are absolutely right. WebElement catches all sorts of things and some may cause the General run error (still a bug with the tool).

I added one more attribute to narrow down the elements and kept the rest same and the code is working now.

Set wElement=Description.Create()
wElement("micclass").Value="WebElement"
wElement("html tag").Value="DIV"

Set cElements=Browser(myBrowser).Page(myPage).ChildObjects(wElement)
ElementsCount=cElements.count()
For i=0 to ElementsCount-1
msgbox cElements(i).GetROProperty("innertext")
If cElements(i).GetROProperty("innertext") = elementName Then
myY = cElements(i).GetROProperty("y")
Exit for
End If
Next

Thanks everyone for your help.
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation