Using user-extension.js in Selenium RC
I'm having a hard time using extensions.js in Selenium RC.
My Java code,
import com.thoughtworks.selenium.*;
import junit.framework.*;
import java.lang.String;
public class javaErrorCheck extends SeleneseTestCase
{
Boolean Result=false;
String S=null;
String Host="localhost";
String Timeout="30000";
public void setUp() throws Exception
{
setUp("http://"+Host+"/", "*iexplore");
}
public static Test suite()
{
return new TestSuite(javaErrorCheck.class);
}
public static void main(String args[])
{
junit.textui.TestRunner.run(suite());
}
public void test_Login() throws Exception
{
selenium.setTimeout(Timeout);
selenium.open("http://"+Host+"/LoginPage.do");
selenium.windowFocus();
selenium.windowMaximize();
selenium.windowFocus();
selenium.getEval("doDisplayAlert('testing','test');");
selenium.type("userName", "admin");
selenium.type("password", "admin");
Result=selenium.isElementPresent("//input[@type='image']");
selenium.click("//input[@type='image']");
selenium.waitForPageToLoad(Timeout);
}
}
my user-extensions.js
Selenium.prototype.doDisplayAlert = function(value, varName)
{
alert(value);
};
When I run this with the getEval () method this error was thrown,
1) test_Login(javaErrorCheck)*com.thoughtworks.selenium.SeleniumException:
ERROR: Threw an exception: Object expected*
at
com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97)
at
com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:91)
at
com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:262)
at
com.thoughtworks.selenium.DefaultSelenium.getEval(DefaultSelenium.java:443)
at javaErrorCheck.test_Login(javaErrorCheck.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at
com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:212)
at javaErrorCheck.main(javaErrorCheck.java:23)
If I use runScript (), the expected object error was thrown in the browser as a JS error. In both cases, a warning is displayed in the RC window. I think selenium was unable to gain control after executing the command.
Any ideas?
+2
a source to share