如何通过 Java 在 Selenium RC 中使用 JavaScript
我在 user-extensions.js 中有以下功能:
Selenium.prototype.doTypeRepeated = function(locator, text) {
// All locator-strategies are automatically handled by "findElement"
var element = this.page().findElement(locator);
// Create the text to type
var valueToType = text + text;
// Replace the element text with the new text
this.page().replaceText(element, valueToType);
};
我正在使用 Selenium RC 和 Java。我有一个 Java 类,我通过以下方式调用了 doTypeRepeated
函数:(
selenium.getEval("doTypeRepeated(\"txtAppCode\", \"service5\")");
"txtAppCode"
是一个文本框,"service5"
是一些要在文本字段上写入/键入的文本)
我收到此错误:
com.thoughtworks.selenium.SeleniumException:
ERROR: Threw an exception: Object expected"
任何人都可以告诉我哪里做错了吗?
I have the following function in user-extensions.js:
Selenium.prototype.doTypeRepeated = function(locator, text) {
// All locator-strategies are automatically handled by "findElement"
var element = this.page().findElement(locator);
// Create the text to type
var valueToType = text + text;
// Replace the element text with the new text
this.page().replaceText(element, valueToType);
};
I am using Selenium RC with Java. I have a Java class and I called the doTypeRepeated
function by following the way:
selenium.getEval("doTypeRepeated(\"txtAppCode\", \"service5\")");
("txtAppCode"
is a textbox and "service5"
is some text to write/type on the textfield)
I got this error:
com.thoughtworks.selenium.SeleniumException:
ERROR: Threw an exception: Object expected"
Can anyone tell me where am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Selenium 修改了 Selenium 原型中额外函数的名称:doFoo 变成了简单的 foo。 (以 is 和 get 开头的函数以类似的方式被破坏。)尝试:
Selenium mangles the names of extra functions in the Selenium prototype: doFoo becomes simply foo. (Functions starting with is and get are mangled in similar ways.) Try: