今天在公司进一步学习了selenium-rc 可是在公司运行正常的最简单的代码,在家里居然报错了 代码如下:
@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*googlechrome ", "http://www.baidu.com/");
selenium.start();
}
后经一番折腾改为:
@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*googlechrome C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", "http://www.headin.cn/");
selenium.start();
}
具体什么原因在成的呢,进一步解密中……
另外报错代码如下:
java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: java.lang.RuntimeException: Google Chrome could not be found in the path! Please add the directory containing ''chrome.exe' or 'google-chrome'' to your PATH environment variable, or explicitly specify a path to Google Chrome like this: *googlechromec:\blah\chrome.exe at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:89) at example.SeleniumTest1.setUp(SeleniumTest1.java:15) 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:50) 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: java.lang.RuntimeException: Google Chrome could not be found in the path! Please add the directory containing ''chrome.exe' or 'google-chrome'' to your PATH environment variable, or explicitly specify a path to Google Chrome like this: *googlechromec:\blah\chrome.exe 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) ... 16 more