In one of my scripts I check using .exist to see if the button is there based on the return value I call an external action.
My problem is that no matter what the script returns a "True" value even if the button is not there.
IsbtnExist = Browser("x"("y").Frame("z").WebButton("submit").Ex ist
if IsbtnExist Then
msgbox "button exists"
msgbox "button does not exits"
The button appears on the web application based on the number of items returned by a search criteria. If nothing is return by the search criteria then it will display "nothing found".
I browser thru some samples that I found here in the forum and tried the same but still not working.
I tried on two different version of qtp 8.0 and 8.2.
From my experience with web applications, sometimes elements exist even though not shown on the page.
What you can try doing is check if the button exist, and if it does check if its visible (your button.GetROProperty("visible") = "True")
I've discovered that boolean values returned by QTP's methods aren't always -1 = True. Sometimes they return as 1 = True. So you must check for the negative.
</font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">If CInt(myBool) <> 0 Then
'it must be true, do some stuff
End If</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">Anyway, the Exist method does not work properly, and more to the point, the visible REALLY does not work properly. It depends on how the web application was constructed. I've performed the .GetROProperty("visible") on many objects that were very obviously not visible on the page and yet the method returns true.
How about checking the properties of the WebButton("submit") as stored in your OR? If there is some other button present on the page which the OR could confuse for 'submit' this could cause the problem too.
Have you tried -
If Browser("y").Frame("z").WebButton("name:=submit"). Exist(1) Then
(I'm hiring Software Development Engineers in Test in Seattle, WA)