Highlighted
Absent Member.
Absent Member.
1770 views

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

0 Likes
3 Replies
Highlighted
Absent Member.
Absent Member.

Re: QTP not returning FALSE if the webelement doesnt exists

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.

 

0 Likes
Highlighted
Honored Contributor.. Honored Contributor..
Honored Contributor..

Re: QTP not returning FALSE if the webelement doesnt exists

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

0 Likes
Highlighted
New Member.

Re: QTP not returning FALSE if the webelement doesnt exists

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...

Accept as solution/Give Kudos to the author if the piece of information answered/helped you to solve your problem.
All the thoughts here are mine not related to my employer nor anyone.
Test Automation Ecstasy
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.