Selenium IDE正在停止javascript
当使用Selenium IDE在网页上记录操作时,应用程序正在停止JavaScript并显示错误消息“太多递归” 我在FireFox 54.0.1上使用Selenium IDE 2.9.1.1 我为测试编写了一个简单的javascript警报,但它也被Selenium阻止Selenium IDE正在停止javascript,javascript,selenium,selenium-ide,Javascript,Selenium,Selenium Ide,当使用Selenium IDE在网页上记录操作时,应用程序正在停止JavaScript并显示错误消息“太多递归” 我在FireFox 54.0.1上使用Selenium IDE 2.9.1.1 我为测试编写了一个简单的javascript警报,但它也被Selenium阻止 <html> <head> <script> function hello(){ alert("Hello\nHow are you?");
<html>
<head>
<script>
function hello(){
alert("Hello\nHow are you?");
}
</script>
</head>
<body>
<input type="button" onclick="hello();" value="Say Hi" />
</body>
</html>
这是因为函数调用实际上在运行时被Selenium自己的JavaScript覆盖。 将下面的Javascript代码添加到selenium core用户扩展中,重启后可以修复此问题
//http://docs.seleniumhq.org/docs/08_user_extensions.jsp
Selenium.prototype.doExecute = function(script) {
this.browserbot.getCurrentWindow().eval(script);
};
Selenium.prototype.getExecute = function(script) {
return this.browserbot.getCurrentWindow().eval(script);
};
Selenium.prototype.getJqMethod = function(selector, method) {
return this.getExecute('$("' + selector + '").' + method + '();');
};
Selenium.prototype.getJqText = function(selector) {
return this.getJqMethod(selector, "text");
};
Selenium.prototype.getJqHtml = function(selector) {
return this.getJqMethod(selector, "html");
};
Selenium.prototype.getJqVal = function(selector) {
return this.getJqMethod(selector, "val");
};
PageBot.prototype.locateElementByJq = function(selector, inDocument) {
// FF/Chrome/IE9+: defaultView, OldIE: parentWindow
return (inDocument.defaultView || inDocument.parentWindow)
.eval("jQuery('" + selector.replace(/'/g, "\\'") + "')[0];");
};
显示您的selenium scriptJust update,异常出现在这里
self.windowMethods['alert'].call(self.window,alert)代码>
//http://docs.seleniumhq.org/docs/08_user_extensions.jsp
Selenium.prototype.doExecute = function(script) {
this.browserbot.getCurrentWindow().eval(script);
};
Selenium.prototype.getExecute = function(script) {
return this.browserbot.getCurrentWindow().eval(script);
};
Selenium.prototype.getJqMethod = function(selector, method) {
return this.getExecute('$("' + selector + '").' + method + '();');
};
Selenium.prototype.getJqText = function(selector) {
return this.getJqMethod(selector, "text");
};
Selenium.prototype.getJqHtml = function(selector) {
return this.getJqMethod(selector, "html");
};
Selenium.prototype.getJqVal = function(selector) {
return this.getJqMethod(selector, "val");
};
PageBot.prototype.locateElementByJq = function(selector, inDocument) {
// FF/Chrome/IE9+: defaultView, OldIE: parentWindow
return (inDocument.defaultView || inDocument.parentWindow)
.eval("jQuery('" + selector.replace(/'/g, "\\'") + "')[0];");
};