1

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?

1
  • I have switched my test into WebDriver from Selenium RC. executeScript() is replacement of getEval() in Selenium 2 (WebDriver) Commented Feb 26, 2013 at 7:13

1 Answer 1

1

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\")");
Sign up to request clarification or add additional context in comments.

6 Comments

Thanks for your reply. I tried by using selenium.getEval("typeRepeated(\"txtAppCode\", \"service5\")"); But I found the following error:
Sorry, which error? "com.thoughtworks.selenium.SeleniumException: ERROR: Threw an exception: Object expected"?
yes, error is:com.thoughtworks.selenium.SeleniumException: ERROR: Threw an exception: Object expected
In my application, there are 2 comb box: i) cmbRFARequires and ii) cmbProcureMethod. After selecting a value/option from 1st combo(cmbRFARequires), 2nd combo value/label is loaded which has been done using Ajax. How can i get value/option from 2nd combo by using Selenium RC? Pls help me
javascript function as Selenium.prototype.doSelect1 = function(locator, optionLocator) { var element = this.page().findElement(locator); if (!("options" in element)) { throw new SeleniumError("Specified element is not a Select (has no options)"); } var locator = this.optionLocatorFactory.fromLocatorString(optionLocator); var option = locator.findOption(element); this.page().selectOption(element, option); };
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.