1

I have following methods of my class Test: (Selenium RC, JUnit, Java, Eclipse)

@Before
public void setUp() throws Exception {
    selenium = new DefaultSelenium("localhost", 4444, "*firefox","https://www.google.com/");
    selenium.start();
   }
@Test
public void testGoogle() throws Exception {
     selenium.open("https://www.google.com");
......
........
     }

After execution of Google site, I want to switch yahoo site from Google. I have written the following code of snippet:

@Test
public void testYahoo() throws Exception {
     selenium.open("http://www.yahoo.com/"); //error in this line
........
........
     }

I found the following errors:

com.thoughtworks.selenium.SeleniumException: Cannot call method 'indexOf' of undefined at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:100) at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:94) at com.thoughtworks.selenium.DefaultSelenium.open(DefaultSelenium.java:343) at abc.Test.testYahoo(Test.java:47) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

How can I open another site rather than Base URL? Please help me

Ripon

0

2 Answers 2

1

It seems you need to close previous selenium session or reuse selenium instance:

private static Selenium selenium;

@BeforeClass
public static void beforeClass() throws Exception {
    selenium = new DefaultSelenium("localhost", 4444, "*firefox","https://www.google.com/");
    selenium.start();
}

@Test
public void testGoogle() throws Exception {
    selenium.open("https://www.google.com");
}

@Test
public void testYahoo() throws Exception {
    selenium.open("https://www.yahoo.com");
}
Sign up to request clarification or add additional context in comments.

Comments

1

Try *chrome instead of *firefox

Comments

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.