QTP not returning FALSE if the webelement doesnt exists

Hi, 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 pls 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

  • Yes , It seems webElement is hidden.

     

    Try searching the element on the current page using any of the property (using view source) , or using firebug in FF /developer tools in IE.

     

  • Is the visible property always True as well? What are the coordinates of the object when it is not visible? If it is rendering at 0, 0, then perhaps you could use that to determine if it is displayed or not?

     

    MsgBox "visible: " & Browser("CDMS :: Master Agreement").Page("CDMS :: Master Agreement").WebElement("File Upload successfully").GetROProperty("visible") & Chr(13) & _

    "abs_x: " & Browser("CDMS :: Master Agreement").Page("CDMS :: Master Agreement").WebElement("File Upload successfully").GetROProperty("abs_x") & Chr(13) & _

    "abs_y: " & Browser("CDMS :: Master Agreement").Page("CDMS :: Master Agreement").WebElement("File Upload successfully").GetROProperty("abs_y")

     

    Thanks,

    Ray

  • Always developers would assign some attribute to make the AJAX elements to be displayed or not.

     

    Check the attributes of that element using firebug or IE developer tools. Normally most of the developers will use display property and you can get the same like;

     

    element.Object.Style.display

     Value should be in-line or block or something if it's visible and hide or "" if it's hidden. But this is not standard; in angular design or MVC based design, they would have custom attribute with custom values.

     

    So analyse your source code and implement accordingly...