如何在使用Selenium RC和Java执行基本URL后打开另一个URL
我有我的类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");
......
........
}
在执行Google网站之后,我想从Google切换雅虎网站。 我已经编写了以下代码片段:
@Test
public void testYahoo() throws Exception {
selenium.open("http://www.yahoo.com/"); //error in this line
........
........
}
我发现了以下错误:
com.thoughtworks.selenium.SeleniumException:无法通过com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:94)在com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:100)处调用未定义的方法'indexOf'在sun.reflect.NativeMethodAccessorImpl.invoke0(本地方法)上的abc.Test.testYahoo(Test.java:47)上的com.thoughtworks.selenium.DefaultSelenium.open(DefaultSelenium.java:343) 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 在org.junit.internal.runners.statements.RunAfters.evaluate处运行org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)处的eMethod.evaluate(InvokeMethod.java:20)(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)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) org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
如何打开另一个网站而不是基本网址? 请帮帮我
里彭
看来你需要关闭以前的硒会话或重用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/90363.html上一篇: How to open another URL after executing base URL by using Selenium RC with Java
下一篇: How do I mock a method inherited from an abstract class with EasyMock?