18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

how to check that an element does not have a certain style

handytomhandytom Members
edited November -1 in Sahi - Open Source
Hi

I use JS to hide/show certain rows of a table and I want SAHI to check that the correct row are hidden or not

When they are hidden the display:none style is added to them and to show them again the style is removed altogether.

It is easy to check that a row has display set to none
_assertTrue(_style(top.document.getElementById('row_1'), 'display') == 'none');
but how do I check that an element doe snot have the display style. When I try the following code I just get a [Exception] [object Error]
_assertTrue(_style(top.document.getElementById('row_1'), 'display') != 'none');
Any ideas?
Cheers
Tom

Comments

  • Or is there even a way just to capture an object error in SAHI?

    I mean the fact that the display style property does not exist and throws an error is good enough for me in indicating that display:none is not set. But all I need to a way to capture the error and verify that we are expecting an error.
  • narayannarayan Administrators
    You should not be getting any exceptions even in your second case. I tested on IE and FF and _style seems to be working fine.
    Could you tell us which browser version you are using, and may be show the table html?

    To see if element itself has not been set you could try:
    _assertEqual('', top.document.getElementById('row_1').style)
  • Great your method works perfectly. Thanks for that.
Sign In or Register to comment.