Selenium IDE:每当按下play按钮时,就会触发Ajax调用
每当用户单击SeleniumIDE中的play按钮时,我都会发出一个Ajax调用。jQuery$.ajax函数会更好。有办法做到这一点吗Selenium IDE:每当按下play按钮时,就会触发Ajax调用,ajax,jquery,selenium,selenium-ide,Ajax,Jquery,Selenium,Selenium Ide,每当用户单击SeleniumIDE中的play按钮时,我都会发出一个Ajax调用。jQuery$.ajax函数会更好。有办法做到这一点吗 在网上搜索了20分钟后,我没有发现有人试图这样做 您可以使用一个Selenium命令来计算JavaScript代码。例如,waitForCondition命令执行JavaScript片段,直到最后一个表达式的计算结果为真。注意,如果测试页面已经有jQuery,那么可以跳过前两部分 将jQuery库加载到页面中 JavaScript代码片段 硒命令 硒命令 硒命
在网上搜索了20分钟后,我没有发现有人试图这样做 您可以使用一个Selenium命令来计算JavaScript代码。例如,
waitForCondition
命令执行JavaScript片段,直到最后一个表达式的计算结果为真。注意,如果测试页面已经有jQuery,那么可以跳过前两部分
将jQuery库加载到页面中
JavaScript代码片段
硒命令
硒命令
硒命令
等待条件
(函数(窗口){window.jQuery.ajax()http://www.google.co.uk/search?q=jquery');})(selenium.browserbot.getUserWindow());1 == 1;
1000
谢谢您的详细回答!下次上班时我会再试一次,然后汇报。这个解决方案非常有效,非常感谢katranci的帮助!
(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 something that evaluates to "true" here to make sure that our code runs only once
<!--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>
typeof selenium.browserbot.getUserWindow().jQuery == 'function'
<!--Validate jQuery-->
<tr>
<td>waitForCondition</td>
<td>typeof selenium.browserbot.getUserWindow().jQuery == 'function'</td>
<td>60000</td>
</tr>
(function(window) {
window.jQuery.ajax('http://www.google.co.uk/search?q=jquery');
})(selenium.browserbot.getUserWindow());
1 == 1;
<!--Make an 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>