18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
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.
ID element issue
Hello,
I'm working with sahi on a site that ID's are not hardcoded on pages, they can be changed at any time. I can follow up the element I'm looking for by a custom attribute that is added to each html tag element and that value is unique.
Is there a way t oget an element by a custom attribute?
i.e. <input id="1" name="1" class="text" customID="342">....
Can I get the element like _input("customID='342'") ???
Or there is a way to use Jquery within sahi??
I'm really new to sahi and I'm trying to solve this issue that I hope would not stop me on the creation of test cases since the ID tags can change without notice
.
Thanks!
Carlos
I'm working with sahi on a site that ID's are not hardcoded on pages, they can be changed at any time. I can follow up the element I'm looking for by a custom attribute that is added to each html tag element and that value is unique.
Is there a way t oget an element by a custom attribute?
i.e. <input id="1" name="1" class="text" customID="342">....
Can I get the element like _input("customID='342'") ???
Or there is a way to use Jquery within sahi??
I'm really new to sahi and I'm trying to solve this issue that I hope would not stop me on the creation of test cases since the ID tags can change without notice
Thanks!
Carlos
This discussion has been closed.
Comments
in your $Sahi_Home/docs/java_client/index.html you'll find a documentation. I hope this will help with your getElementBySomething issue. If not, please excuse me for wasting your time
Regards
Wormi
I have searched there and what could be useful is _byXpath.
I have added the javascript-xpath.js on the specified location: <$sahi_home\htdocs\spr>
I have restarted the Sahi but this still coldn't work.
I have no control over the html so I need to fund this input, select, table.. tags.
All my elements are inside a DIV called "screen"
<div id="screen">
<input id="234" class="something" customID="467">
</div>
What I need is to acces that input with the customID attribute. So I was trying this on the dashboard:
_byXPath("//input[(at)customID=467]",_in(_div("dScreen")));
(using (at) since I cannot print that symbol)
But I see this on the results box
[Exception] [object Error]
I really need to find a solution into to that since I have no other choice that to find the elements by that customID.
Thanks!
Carlos
You can directly use jquery locators in Sahi. Use jquery("id") instead of $("id") since $ has a special meaning in Sahi.
You can also modify Sahi so that it identifies all elements by customID. For that
1) Open sahi/spr/concat.js
2) Search for statements like this: 3) In the attributes array, add "customID" as the first parameter, so that it looks like 4) Save and restart Sahi.
Now Sahi will identify by customID also.
Hope that helps.
Regards,
Narayan
Thanks so much for your answer!! that really solved my problem. So now I can create my Test Cases veeery easy with this site
Thanks so much again!
I think this is valuable info.
Carlos