How to open another URL after executing base URL by using Selenium RC with Java

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.Invok eMethod.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.jav a: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


看来你需要关闭以前的硒会话或重用selenium实例:

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");
}

试试* chrome而不是* firefox

链接地址: http://www.djcxy.com/p/90364.html

上一篇: 没有可用于RDF格式JSON的解析器工厂

下一篇: 如何在使用Selenium RC和Java执行基本URL后打开另一个URL