I'm using selenium 2.8. I am getting a crazy error like this:
testPersistence(com.***.***.selenium.test.PersistenceTest) Time elapsed: 0.032 sec <<< ERROR!
java.lang.RuntimeException: Could not start Selenium session: ^@
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:107)
at com.***.***.selenium.test.PersistenceTest.testPersistence(PersistenceTest.java:37)
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.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.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:120)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:103)
at org.apache.maven.surefire.Surefire.run(Surefire.java:169)
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.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
Caused by: com.thoughtworks.selenium.SeleniumException: ^@
at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:112)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:106)
at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:275)
at com.thoughtworks.selenium.HttpCommandProcessor.start(HttpCommandProcessor.java:237)
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:98)
... 28 more
my test class is very simple. its got a test like thislike this:
@Test
public void testPersistence() throws InterruptedException {
DefaultSelenium selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:8080");
selenium.start();
selenium.waitForPageToLoad("30000");
selenium.open("/***/register.seam");
selenium.waitForPageToLoad("30000");
selenium.type("registration:username", "jackman");
Thread.sleep(5000);
selenium.type("registration:name", "Jack Daniels");
Thread.sleep(5000);
selenium.type("registration:password", "123456789");
Thread.sleep(5000);
selenium.click("registration:register");
selenium.waitForPageToLoad("30000");
Thread.sleep(5000);
assertTrue(selenium.isTextPresent("regexpi:Welcome"));
selenium.stop();
}
Can anyone help me please?
thanks in advance
Your pom.xml is missing, so hard to judge what's going wrong.
However, in a simple test project, I only need in my pom.xml the following in the "dependencies" section (note, I'm using Selenium 2.22.0 instead of 2.8):
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<scope>test</scope>
<version>2.22.0</version>
</dependency>
I invoke my tests using TestNG, but it should also work with JUnit.
My test case looks as follows. I stripped out everything related to proxy settings, so the example could probably even be simplified:
FirefoxProfile profile = new FirefoxProfile();
FirefoxBinary firefoxBinary = new FirefoxBinary();
WebDriver driver = new FirefoxDriver(firefoxBinary, profile);
driver.get("http://www.google.com");
Assert.assertEquals("Google", driver.getTitle().trim());
So one problem could be that you are using an outdated version of Selenium (2.8). Also the way you set up your DefaultSelenium looks wrong to me. Also, for Firefox you don't need the Selenium server running.
Another thing I don't understand is the wait for 30 seconds directly after starting selenium. What are you waiting for?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With