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("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;</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
Post a Comment