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.

Object not identified properly with _near()

anoop.philipanoop.philip Members
edited November -1 in Sahi - Open Source
Users Status

User1 [edit icon]
User2 Deactivated
User3 [edit icon]
User4 Deactivated


In the above list if the user is active it will show a edit icon, where it opens the edit page when clicking. If deactivated it will show a "Deactivated" text.

I want to check whether the status of "user4" is deactivated and pass if it is the same. If the status of the user is something else (the edit icon) the test should fail. I tried the following assersion

_assertExists(_cell("Deactivated"), _near(_cell("user4")));
_assert(_isVisible(_cell("Deactivated"), _near(_cell("user4"))));

The problem i'm facing is the test is passing even if the "user4" is not present in the list. It is taking the value of "user2" and passing the test.

Tried using _in() and _under() also.. didn't work
Please let me know how can I do this test properly.

Sahi version: OS 3.5
Browser: FF 3.6.24
OS: Windows 2003

Comments

  • looks I made mistake in script above, misplaced brackets. yet the result is same

    _assertExists(_cell("Deactivated", _near(_cell("user4"))));
    _assert(_isVisible(_cell("Deactivated", _near(_cell("user4")))));

    Regards,
    Anoop
  • Hi anoop.philip,

    You will have to use a condition to work with the above code.

    Explanation:

    _assertExists(_cell("deactivated", _near(_cell("user4")))); will return true because it is referenced with user4 which is not visible but is hidden.

    Use:

    if(_isVisible(_cell("user4")))
    _assertExists(_cell("deactivated", _near(_cell("user4"))));
    else
    _alert("fail");

    Regards
    Sumitra
  • Thanks for the solution. But the solution u provided is working if the item is not visible in the list. If the item is visible and have a different status it is not working. It is passing the test. ("User4" is present in the list, but status is "Active")

    Users Status

    User1 Blocked
    User2 Deactivated
    User3 Active
    User4 Active

    The code you provided is passing the test for the above list. I want to pass the test only if the status of "User4" is "Deactivated".
  • Hi anoop.philip,

    You can use:

    _assertContainsText("deactive", _cell(0, _near(_cell("user4")), _under(_cell("status"))));

    Regards
    Sumitra
  • Test always fails for any status (Deactivated or anything else) of User4 when tried the code.

    Code used in script (instead of User4 it is TestUser4 and instead of Status it is Action described in the previous posts):
    _assert(_isVisible(_cell("TestUser4")));
    _assertContainsText("Deactivated", _cell(0, _near(_cell("TestUser4")), _under(_cell("Action"))));

    It showed me the following error when opened the log file:
    Test Total Steps Failures Errors Success Rate Time Taken (ms)
    test.sah 2 0 1 50% 12282

    Starting script
    _assert(_isVisible(_cell("TestUser4"))); at Dec 15, 2011 2:07:37 PM
    _assertContainsText("Deactivated", _cell(0, _near(_cell("TestUser4")), _under(_cell("Action"))));
    TypeError: obj is null
    http://s-ws.testurl.net/_s_/spr/concat.js:906
    http://s-ws.testurl.net/_s_/spr/concat.js:893
    http://s-ws.testurl.net/_s_/spr/concat.js:3856
    http://s-ws.testurl.net/_s_/spr/concat.js:3016
    http://s-ws.testurl.net/_s_/spr/concat.js:3016
    http://s-ws.testurl.net/_s_/spr/concat.js:2822
  • Sorry for the confusion. It is working.
    Instead of_tableHeader("Action") I used _cell("Action") in the code which resulted in unidentifying the object during playback.
    It worked fine!! Thanks a lot :)
This discussion has been closed.