Sahi Pro - How does Sahi identify elements?
Sahi can identify elements in various ways.Standard attributes
Sahi has access to the DOM of the html page. Thus it can identify elements using their attributes. Depending upon the type of the element, Sahi uses the visible text, name, id, class, associatedLabel, index etc to identify the element. More details can be found in the Accessor APIs section.Custom attributes
It is also possible to add a custom property to an element and have Sahi identify the element through the custom property.Let us say you had a custom identifier called customid in your checkbox element.
You can make the following changes to have the Sahi controller identify the checkbox element by its customid.
- Take a backup of htdocs/spr/concat.js.
- Edit concat.js. Search for the line containing
this.addAD({tag: "INPUT", type: "checkbox"
- Replace the following line
withthis.addAD({tag: "INPUT", type: "checkbox", event:"click", name: "_checkbox", attributes: ["name", "id", "value", "className", "index"], action: "_click", value: "checked", assertions: function(value){return [("true" == ("" + value)) ? _sahi.language.ASSERT_CHECKED : _sahi.language.ASSERT_NOT_CHECKED];}});
this.addAD({tag: "INPUT", type: "checkbox", event:"click", name: "_checkbox", attributes: ["name", "id", "value", "className", "index", "customid"], action: "_click", value: "checked", assertions: function(value){return [("true" == ("" + value)) ? _sahi.language.ASSERT_CHECKED : _sahi.language.ASSERT_NOT_CHECKED];}});
infoNOTE the addition of "customid". - Restart Sahi server and clear browser cache.
- Now a checkbox can be identified through the "customid" attribute as well.