Sahi Pro - Tweaking Sahi APIs

Identifying elements by an attribute not available with Sahi

It is possible that Sahi does not use your desired element attribute while identifying elements.
For example one of our users wished to use the "title" attribute of a button
<input  type="button" title="findMe">
To add title as one of the attributes, do the following:
  1. Open sahi/htdocs/spr/concat.js
  2. Search for
  3. this.addAD({tag: "INPUT", type: "button", event:"click", name: "_button",
    attributes: ["value", "name", "id", "index", "className"],
    action: "_click", value: "value"});
  4. Add "title" to the list of attributes so that
  5. attributes: ["value", "name", "id", "index", "className"]
    becomes
    attributes: ["value", "name", "id", "index", "title", "className"]
    The full line looks like this after the change:
    this.addAD({tag: "INPUT", type: "button", event:"click", name: "_button",
    attributes: ["value", "name", "id", "index", "title", "className"],
    action: "_click", value: "value"});
  6. Save the file, restart Sahi and clear browser cache.
From now on Sahi will identify buttons by their title also.
NOTES:
  1. Any attribute of the HTML element can be used for identification. So if you are using a framework which introduces something like widgetID="myId", you can add "widgetID" in the above attributes list.
  2. The order of the attributes is significant. So if you wish to move "title" to be the default attribute, make it
  3. attributes: ["title", "value", "name", "id", "index", "className"]
  4. When an attribute is added, regular expression matching, adding of index for duplicates etc. are handled automatically by Sahi.
infoNOTE: title is now added by default to Sahi