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.

Test whether an image is not present for a particular entry in a table

anoop.philipanoop.philip Members
edited November -1 in Sahi - Open Source
If a table entry is editable it will show an edit icon (image) right to the corresponding table entry under the header Action. If non editable it will show a text.
How do i test whether a table entry is non editable by verifying the missing edit icon for that particular entry?

I tried the following code, it is not working.
_assertNotTrue(_isVisible(_image("b_edit.png", _near(_cell("User4")), _under(_tableHeader("Action")))));

for the above code, if some other item in the list has the edit icon it is recognizing that and fails the test.

Comments

  • Hi anoop,

    Try with

    _assertNotExists(_image("b_edit.png", _near(_cell("User4")), _under(_tableHeader("Action"))));

    This might help you.

    Regards,
    Theeran.
  • Hi Theeran,

    I tried this. Test is failing if any of the items in the list has the edit option, not only "User4".
    ie. test is failing if _image("b_edit.png") is present anywhere on the page.

    Regards,
    Anoop
  • narayannarayan Administrators
    Anoop and Theeran,

    Using the _near API when an element MAY or MAY NOT be present, is a bad idea. Since _near is a fuzzy API, it will find you the nearest image even if it is on the next row!

    The way to use it, is to find the placeholder element which may or may not contain the image. In your case it may be like this:

    _cell(0, _near(_cell("User4")), _under(_tableHeader("Action")))

    Then access the image inside it.

    _image("b_edit.png", _in(_cell(0, _near(_cell("User4")), _under(_tableHeader("Action")))))

    Note that the cell will always give you the table cell under Action. _in will give you the image inside it. _in is not a fuzzy API.

    _assertNotTrue(_isVisible(_image("b_edit.png", _in(_cell(0, _near(_cell("User4")), _under(_tableHeader("Action")))))))

    may be the expression you are looking for.

    To make this more readable, you could do something like this:

    var $cell = _cell(0, _near(_cell("User4")), _under(_tableHeader("Action")));
    _assertNotTrue(_isVisible(_image("b_edit.png", _in($cell))));

    Regards,
    Narayan
  • Thanks Narayan,
    It works perfectly. Brilliant!!!

    Regards,
    Anoop
This discussion has been closed.