2016-07-27 12 views
-1

ヘッドレス自動化のためにSeleniumでPhantomJを使用しています。それは今日まで私にとってうまくいった。 PhantomJsドライバを初期化するときに、以下の例外が発生します。次のようにセレンを含むPhatntomJsはセッションを開始できません

私が使用していたコードは次のとおりです。

Capabilities caps = new DesiredCapabilities(); 
((DesiredCapabilities) caps).setJavascriptEnabled(true); 
((DesiredCapabilities)caps).setCapability("phantomjs.binary.path", System.getProperty("user.dir") 
       + "\\src\\main\\resources\\phantomjs.exe"); 

WebDriver driver = new PhantomJSDriver(caps); 

がERROR:

 Jul 27, 2016 9:20:01 PM 
org.openqa.selenium.phantomjs.PhantomJSDriverService INFO: 
executable: C:\Users\Ajatshatru 
Singh\workspace\Assignment\src\main\resources\phantomjs.exe Jul 27, 
2016 9:20:01 PM org.openqa.selenium.phantomjs.PhantomJSDriverService 
INFO: port: 48904 Jul 27, 2016 9:20:01 PM 
org.openqa.selenium.phantomjs.PhantomJSDriverService INFO: 
arguments: [--webdriver=48904, --webdriver-logfile=C:\Users\Ajatshatru 
Singh\workspace\Assignment\phantomjsdriver.log] Jul 27, 2016 9:20:01 
PM org.openqa.selenium.phantomjs.PhantomJSDriverService INFO: 
environment: {} Exception in thread "main" 
org.openqa.selenium.remote.UnreachableBrowserException: Could not 
start a new session. Possible causes are invalid address of the remote 
server or browser start-up failure. Build info: version: '2.39.0', 
revision: '14fa800511cc5d66d426e08b0b2ab926c7ed7398', time: 
'2013-12-16 13:18:38' System info: host: 'Ajatshatru', ip: 
'10.31.32.236', os.name: 'Windows 8', os.arch: 'amd64', os.version: 
'6.2', java.version: '1.7.0_51' Driver info: driver.version: 
PhantomJSDriver at 
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548) 
    at 
org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216) 
    at 
org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:111) 
    at 
org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:115) 
    at 
org.openqa.selenium.phantomjs.PhantomJSDriver.(PhantomJSDriver.java:110) 
    at 
org.openqa.selenium.phantomjs.PhantomJSDriver.(PhantomJSDriver.java:99) 
    at Partik.Assignment.WebDriverQueue.main(WebDriverQueue.java:37) 
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting 
for driver server to start. Build info: version: '2.39.0', revision: 
'14fa800511cc5d66d426e08b0b2ab926c7ed7398', time: '2013-12-16 
13:18:38' System info: host: 'Ajatshatru', ip: '10.31.32.236', 
os.name: 'Windows 8', os.arch: 'amd64', os.version: '6.2', 
java.version: '1.7.0_51' Driver info: driver.version: PhantomJSDriver 
    at 
org.openqa.selenium.remote.service.DriverService.start(DriverService.java:165) 
    at 
org.openqa.selenium.phantomjs.PhantomJSCommandExecutor.execute(PhantomJSCommandExecutor.java:78) 
    at 
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527) 
    ... 6 more Caused by: 
org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting 
for [http://localhost:48904/status] to be available after 20004 ms at 
org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104) 
    at 
org.openqa.selenium.remote.service.DriverService.start(DriverService.java:163) 
    ... 8 more Caused by: 
com.google.common.util.concurrent.UncheckedTimeoutException: 
java.util.concurrent.TimeoutException  at 
com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:143) 
    at 
org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:79) 
    ... 9 more Caused by: java.util.concurrent.TimeoutException  at 
java.util.concurrent.FutureTask.get(Unknown Source) at 
com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130) 
    ... 10 more

答えて

0

まあ、単純な再起動は私のためにそれをやりました。 :|

関連する問題