如何在Selenium RC和Java中使用JavaScript

如何在Selenium RC和Java中使用JavaScript,java,javascript,selenium,selenium-rc,Java,Javascript,Selenium,Selenium Rc,我在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

我在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"

有人能告诉我哪里做错了吗?

Selenium破坏了Selenium原型中额外函数的名称:doFoo变成了foo。(以is和get开头的函数以类似方式损坏。)尝试:


谢谢你的回复。我尝试使用selenium.getEval(“typeRepeated(\“txtAppCode\”,“service5\”);但是我发现了以下错误:对不起,哪个错误?“com.thoughtworks.selenium.SeleniumException:错误:引发异常:预期的对象”?是的,错误是:com.thoughtworks.selenium.SeleniumException:错误:引发异常:预期的对象请帮助我解决此问题。在我的应用程序中,有两个梳框:i)CMBRFareRequests和ii)cmbProcureMethod。从第一个组合中选择值/选项(cmbRFARequires)后,将加载使用Ajax完成的第二个组合值/标签。如何使用Selenium RC从第二个组合中获取值/选项?请帮助我将我的测试从Selenium RC转换为WebDriver。executeScript()是Selenium 2(WebDriver)中getEval()的替代品
selenium.getEval("typeRepeated(\"txtAppCode\", \"service5\")");