开发者

How to use JavaScript in Selenium RC with Java

开发者 https://www.devze.com 2023-02-11 15:38 出处:网络
I have the following function in user-extensions.js: Selenium.prototype.doTypeRepeated = function(locator, text) {

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 an开发者_StackOverflow社区yone tell me where am I doing wrong?


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:

selenium.getEval("typeRepeated(\"txtAppCode\", \"service5\")");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号