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.

Sahi identifier question

candelacandela Members
edited December 2009 in Sahi - Open Source
Hi, I have to evaluate Selenium for automation but I came across Sahi which seems also interesting

However, I don't understand how to solve the following problem. In the documentation I see

API _button(identifier[, domRelation])
HTML <input type="button" name="name" id="id" value="value">
HTML <button type="button" name="name" id="id">value</button>
Identifier index, value, name, id


There seems to be no way to explicitly define the type of identifier. Suppose a button with id="button1" is by mistake replaced with a button with value="button1". A Sahi script looking for _button("button1") will not detect this and keep on working even though there is an error on the page. With Selenium you can explicitly look for a button with the id="button1".

Comments

  • narayannarayan Administrators
    Candela,

    Given that Sahi is a functional testing tool, Sahi tries to keep the details of the HTML page away from testers. We have seen that depending on explicit attributes for identification makes the tests more brittle, and more work for maintenance. If what you want is an assertion on the value of the button, you could add it explicitly using
    _assertEqual("button1", _button("button1").value);

    Once you start working on your scripts, you will realize how much easier it is to work with Sahi's APIs.
    Does anyone else on the forums have any views on this?

    Regards,
    Narayan
  • JordanJordan Members
    This is loosley related to the subject, but what the heck is a domRelation? I wish the API documentation had examples like the basic scripting section does.
  • Pratyush_TytoPratyush_Tyto Members
    edited June 2013
    Hi Jordan,
    Hi,
    The API documentation that Candela has mentioned is from
    http://sahi.co.in/w/browser-accessor-apis
    

    Regarding your question on domRelation, as the link says,
    When elements are not uniquely identifiable by themselves, we should try to identify them  in relation to either some element near them or by the element in which they are contained.
    _near is a DOM relation marker which specifies that the element should be searched near another element.
    _in is a DOM relation marker which specifies that the element should be searched within    another element.
    

    Sahi can identify elements with respect to other elements on the page using _near, _under, _in etc. This is what is meant by domRelation (relation according to the DOM structure).

    Regards.
  • Thats why your button ids/values can change over time, thats a pretty neat thing about sahi. You can make modifications on your HTML and the tests will pass as long as you do not change the behavior of your website.
Sign In or Register to comment.