This is a migrated thread and some comments may be shown as answers.

Unable to verify Element Visibility for IF statement.

5 Answers 259 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ajit
Top achievements
Rank 1
Ajit asked on 19 Jan 2015, 08:39 AM
Hi All,

I am Unable to verify Element Visibility for IF statement.

The scenario is I am using test step(Quick Step) as "Verify if Visible"
But getting this Exception in case of failure(Element is not visible.).

'*/**/**** 1:56:17 PM' - 'Fail' : 38. IF (Verify element 'ELEMENT_Tag' 'is' visible.)
'*/**/**** 1:56:17 PM' - Unable to determine logical branch to go into. Unable to execute verification.

Failure Information:
~~~~~~~~~~~~~~~
Unable to locate element. Details: Attempting to find [Html] element using
Find logic
 (Html): [tagname 'Exact' h1] AND [TextContent 'StartsWith' Server Error in]

Unable to locate element. Search failed!

Learn more about finding elements here:
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/troubleshooting_guide/test-execution-problems/unable-to-locate-element.aspx
------------------------------------------------------------
'*/**/**** 1:56:17 PM' - Detected a failure. Step is marked 'ContinueOnFailure=False' aborting test execution.


Please let me know the solution ASAP.

Thanks,
Ajit.

5 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 21 Jan 2015, 11:19 PM
Hi Ajit,

It's a common misconception that "Verify is visible" is testing whether or not the target UI element can be seen within the browsers window. It actually isn't testing that. The "Verify if Visible" step assumes the element exists somewhere in the browsers DOM (but could be hidden underneath another element or scrolled out of view). Test Studio is checking the visibility state of the element which could be set via CSS and a class name. It's looking for an attribute like "DISPLAY: NONE". If this is present the element is not visible and the browser won't try to paint it. If this attribute is not present the element is visible and the browser will try to paint at at the appropriate time.

However if the element does not exist in the browsers DOM, Test Studio is unable to test the visibility property. Thus you are getting the error "Unable to locate element. Search failed!". It's sort of like asking "is the color of this car Red" when there is no car to look at. Test Studio is coming back and saying "What car?".

You most likely want to replace your "Verify If Visible" with a "Verify Element Exists" step.

Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Shashi
Top achievements
Rank 1
answered on 22 Jan 2015, 12:18 AM
Cody,

I don't know if there is already a feature request for this or not - but I have always wished Verify Visible and Wait for Visible would return false (instead of throwing an exception) when the element does not exist.  I think this would be perfectly acceptable behavior.  Going with your analogy - if the red car does not exist, then it is not visible :).

This would make test code more concise - as we then don't have to check for existence and then check for visibility (in a nested if statement).  You could write something to the log or have an option to handle those scenarios where the test does need to distinguish between existence and visibility.

Shashi
0
Cody
Telerik team
answered on 24 Jan 2015, 06:04 PM
Hi Shashi,

Tell you what, we have this public feed back portal where customers such as yourself can create their own feature requests. Would you mind creating one in your own words how you feel Verify Visible and Wait for Visible should behave? Our development team monitors these requests very closely. The more up votes it gets, the higher the priority it gets in our large list of all feature requests.

Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Shashi
Top achievements
Rank 1
answered on 25 Jan 2015, 03:51 AM
I have already expressed this on the Feature Request page - see my comment from October 2014 in http://feedback.telerik.com/Project/161/Feedback/Details/127428-what-a-verify-isvisible-actually-does-is-not-intuitive .  I also liked the feature request.

Shashi
0
Cody
Telerik team
answered on 25 Jan 2015, 04:26 PM
Hi,

That's great! Thanks.

Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Ajit
Top achievements
Rank 1
Answers by
Cody
Telerik team
Shashi
Top achievements
Rank 1
Share this question
or