Как открыть другой URL после выполнения базового URL с помощью Selenium RC с Java - PullRequest
1 голос
/ 28 декабря 2011

У меня есть следующие методы моего класса 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 я хочу переключить сайт Yahoo с Google.Я написал следующий код фрагмента:

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

Я обнаружил следующие ошибки:

com.thoughtworks.selenium.SeleniumException: Невозможно вызвать метод indexOf из undefined atcom.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError (HttpCommandProcessor.java:100) по адресу com.thoughtworks.selenium.HttpCommandProcessor.doCommand (HttpCommandProcessor.java:94 в abc.Test.testYahoo (Test.java:47) в sun.reflect.NativeMethodAccessorImpl.invoke0 (собственный метод) в sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.jref39).DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) в java.lang.reflect.Method.invoke (Method.java:597) в org.junit.runners.model.FrameworkMethod $ 1.ralljet:.junit.internal.runners.model.ReflectiveCallable.run (ReflectiveCallable.java:15) в организации.junit.runners.model.FrameworkMethod.invokeExplosively (FrameworkMethod.java:42) в org.junit.internal.runners.statements.InvokeMethod.evaluate (InvokeMethod.java:20) в org.junit.efores..evaluate (RunBefores.java:28) в org.junit.internal.runners.statements.RunAfters.evaluate (RunAfters.java:30) в org.junit.runners.ParentRunner.runLeaf (ParentRunner.java:263) в орг.junit.runners.BlockJUnit4ClassRunner.runChild (BlockJUnit4ClassRunner.java:68) в org.junit.runners.BlockJUnit4ClassRunner.runChild (BlockJUnit4ClassRunner.java:47) в org.jun.jun.junorg.junit.runners.ParentRunner $ 1.schedule (ParentRunner.java:60) в org.junit.runners.ParentRunner.runChildren (ParentRunner.java:229) в org.junit.runners.ParentRunner.access $ 000 (ParentRun:50) в org.junit.runners.ParentRunner $ 2.evaluate (ParentRunner.java:222) в org.junit.runners.ParentRunner.run (ParentRunner.java:300) в org.eclipse.jdt.internal.junit4.runner.июньit4TestReference.run (JUnit4TestReference.java:49) в org.eclipse.jdt.internal.junit.runner.TestExecution.run (TestExecution.java:38) в org.eclipse.jdt.internal.junit.runner.Restsr (RemoteTestRunner.java:467) в org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java:683) в org.eclipse.jdt.internal.junit.runner.RemoteRunner.RemoteTestRun390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (RemoteTestRunner.java:197)

Как открыть другой сайт, а не базовый URL?Пожалуйста, помогите мне

Ripon

Ответы [ 2 ]

1 голос
/ 28 декабря 2011

Попробуйте * хром вместо * Firefox

1 голос
/ 28 декабря 2011

Кажется, вам нужно закрыть предыдущий сеанс селена или повторно использовать 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");
}
...