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.
How to include custom js libraries with sahi
How to use jquerry in sahi .Where should I include the jquerry js file .
Comments
If your web application already uses jquery, you do not need to do anything. You can use jquery accessors in your code.
Example script:
If your application does not use jQuery,
1) Copy the jquery.js and other files to sahi/htdocs/spr directory
2) Add a script tag for jquery.js in sahi/config/inject_top.txt, so that it looks like:
Restart Sahi and it should work for you.
Regards,
Narayan
so we can write entire script like
_sahi(
//jquery expression
//YUI expresssion
//any javascript expression
)
I have included jquery.js as described and I am trying the following However I am getting
Should I define it as a sahi function
or is there any other reason to fail ?
the lib is here: {SAHI_HOME}\htdocs\spr\jquery-1.6.2.min.js
I am trying to run jQuery as here:
jQuery.post("http://myapp:9080/ws/", function(data) { alert("Data Loaded: " + data); });
Lech
Did you include it in inject_top.txt or in any other way?
Regards,
Narayan
This is my inject_top.txt
Note, I am using sahi 20101103
When you include the jquery library via inject_top.txt, it will be available on the browser. You would be able to use it like:
_click(jQuery("id"));
but not use it directly in a script. If you want to actually post data using jquery from a script, copy jquery-1.6.2.min.js to your scripts folder, rename jquery-1.6.2.min.js as jquery-1.6.2.min.sah and use _include to include it in your script.
Regards,
Narayan
Hi Narayan,
Our site is already using jquery, but still i got an error, and
Moreover, i also tried injecting the jquery but still got the same error results.
And i also tried,
but, got no good result as well.
Thanks.
<script src="/_s_/spr/domainfix.js"></script>
<script src='/_s_/spr/concat.js' id='_sahi_concat'></script>
<script src='/_s_/spr/jquery.js'></script>
My Application IS Using Jquery
HTML CODE:: AM NOT ABLE TO PICK THIS CUSTOMID ATTRIBUTE THRU JQUERY
<input type="text" customid="dtbill" > hello </input>
//(1) ERROR = "$" is not defined
var $d = _getText($("dtbill"));
_log($d);
//(2)
//from http://api.jquery.com/attribute-starts-with-selector/
$('input[customid="dtbill"]').val('21/2/2012');
I followed your advice in your first post and got JQuery calls working when the scripts are run in IE. However, the library isn't included when I run the scripts in Firefox (v30.0). Any suggestions?