jquery - Selenium IDE: Firing off an Ajax call whenever the play button is pressed -


i'd fire off ajax call whenever user clicks play button in selenium ide. jquery $.ajax function better. there way this?

after 20 minutes searching online, haven't found trying this.

you can use 1 of selenium commands evaluates javascript code. example waitforcondition command executes javascript snippet until evaluation of last expression true. note can skip first 2 part if test page has jquery.

load jquery library page

javascript snippet

(function(window) {     var script = window.document.createelement("script");     script.src = "http://code.jquery.com/jquery-1.9.1.min.js";     script.type = "text/javascript";     window.document.getelementsbytagname("head")[0].appendchild(script); })(selenium.browserbot.getuserwindow()); 1 == 1; // put evaluates "true" here make sure our code runs once 

selenium command

<!--inject jquery--> <tr>     <td>waitforcondition</td>     <td>(function(window) { var script = window.document.createelement(&quot;script&quot;); script.src = &quot;http://code.jquery.com/jquery-1.9.1.min.js&quot;; script.type = &quot;text/javascript&quot;; window.document.getelementsbytagname(&quot;head&quot;)[0].appendchild(script); })(selenium.browserbot.getuserwindow()); 1==1;</td>     <td>1000</td> </tr> 

validate jquery has been downloaded , ready use

javascript snippet

typeof selenium.browserbot.getuserwindow().jquery == 'function' 

selenium command

<!--validate jquery--> <tr>     <td>waitforcondition</td>     <td>typeof selenium.browserbot.getuserwindow().jquery == 'function'</td>     <td>60000</td> </tr> 

make ajax call

javascript snippet

(function(window) {     window.jquery.ajax('http://www.google.co.uk/search?q=jquery'); })(selenium.browserbot.getuserwindow()); 1 == 1; 

selenium command

<!--make ajax call--> <tr>     <td>waitforcondition</td>     <td>(function(window) {window.jquery.ajax('http://www.google.co.uk/search?q=jquery'); })(selenium.browserbot.getuserwindow()); 1 == 1;</td>     <td>1000</td> </tr> 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -