日食helios; junit,selenium-java-client-driver,selenium-server libs。 添加了lib作为外部jar项目。 写了简单的测试:
import com.thoughtworks.selenium.SeleneseTestCase;
public class FirstTest extends SeleneseTestCase{
public void setUp() throws Exception {
setUp("nedoma.com.ua", "*googlechrome");
}
public void testSignIn() {
String login = "XXXXX";
String password = "XXXXXXXXXX";
selenium.open("nedoma.com.ua");
selenium.click("Увійти");
selenium.type("login" , login );
selenium.type("password" , password );
selenium.submit("Увійти");
selenium.open("http://nedoma.com.ua/settings/profile/");
assertEquals(selenium.getText("profile_name").toLowerCase(), login.toLowerCase());
selenium.close();
}
使用“java -jar selenium-server.jar -multiWindow”命令在cmd中运行selenium-server.jar 将测试作为junit测试。
问题是:失败追踪:
java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: Error while launching browser
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:89)
at com.thoughtworks.selenium.SeleneseTestBase.setUp(SeleneseTestBase.java:123)
at com.thoughtworks.selenium.SeleneseTestBase.setUp(SeleneseTestBase.java:104)
at com.thoughtworks.selenium.SeleneseTestCase.setUp(SeleneseTestCase.java:78)
at src.testSuit.FirstTest.setUp(FirstTest.java:10)
at junit.framework.TestCase.runBare(TestCase.java:132)
at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:212)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
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)
Caused by: com.thoughtworks.selenium.SeleniumException: Failed to start new browser session: Error while launching browser
at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:91)
at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:262)
at com.thoughtworks.selenium.HttpCommandProcessor.start(HttpCommandProcessor.java:223)
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:81)
... 19 more
我做错了什么?请帮忙。 等待任何建议。
P.S。使用* googlechrome尝试与* chrome或* firefox相同的结果。
答案 0 :(得分:0)
尝试在代码的setUp()
函数中启动Selenium服务器,如 -
RemoteControlConfiguration settings = new RemoteControlConfiguration();
settings.setReuseBrowserSessions(true);
settings.setSingleWindow(false);
SeleniumServer seleniumserver=new SeleniumServer(settings);
seleniumserver.boot();
seleniumserver.start();