I have user-extensions.js that contain the following code of snippet:
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 want to call this function from java code using Selenium RC for a text field ("css=input.text"). How can I call this?
From a top of my head you should be able to call your code the following way:
selenium.getEval("Selenium.prototype.doTypeRepeated('input.text', 'some text');");
However, if following suggested approach you should do like
HttpCommandProcessor proc;
proc = new HttpCommandProcessor("localhost", 4444, "*iexplore", "http://google.com/");
Selenium selenium = new DefaultSelenium(proc);
string[] inputParams = {"css=input.text", "Hello World"};
proc.DoCommand("doTypeRepeated", inputParams);
And not forget to start selenium as
java -jar selenium-server.jar -userExtensions user-extensions.js
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.