I am having difficulty in using the extensions.js in Selenium RC.
My Java Code is,
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 is
Selenium.prototype.doDisplayAlert = function(value, varName)
{
alert(value);
};
When I run this using 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(), object expected error was thrown in the browser as a JS error. In both the cases, alert is shown in the RC window. I think, selenium couldn't get the control after executing the command.
Any Ideas?