Reputation: 11
I am trying to validate whether a webelement property exists on the page or not. But QTP always returns "true" and not displaying FALSE if the object doesnt exists. Below is my code. Somebody please help
BlnResult = Browser("CDMS :: Master Agreement").Page("CDMS :: Master Agreement").WebElement("File Upload successfully").Exist(0) Then
Msgbox BlnResult
QTP always returns "true" even in case if web element doesnt exist on the page. when tried doing object spy, QTP recognizes the page, but not highlighting anything. Does it mean the object exists (like Hidden )? Please help
Upvotes: 1
Views: 608
Reputation: 15390
Exist method does not check if the element is visible or not. Even if it is hidden using CSS, it will still return TRUE.
So, Try something like this. (Here we check element coordinates. If it is present in the UI, they will have some coordinates. Not 0)
Set FileUpload = Browser("CDMS :: Master Agreement").Page("CDMS :: Master Agreement").WebElement("File Upload successfully")
If FileUpload.GetROProperty("x") <> "0" AND FileUpload.GetROProperty("y") <> "0" Then
Msgbox "Success"
Else
Msgbox "Failed"
End If
Upvotes: 2