I am using PhantomJs with Selenium for headless automation. It worked well for me until today. Now, I am getting the below exception when I am initializing the PhantomJs driver.
The code I am using is as follows:
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
Well a simple restart did it for me. :|
Related
I am using Cucumber and Java to automate Selenium test cases. Using Jenkins to execute the job. The job is scheduled to run every day. However, after a few test case runs, my task failed with the following error, which is an intermittent problem. Is there anything that can be done in this scenario?
Error:
org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:29896
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'QTSAUTOMATION', ip: '10.2.0.166', os.name: 'Windows Server 2012 R2', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_241'
Driver info: driver.version: RemoteWebDriver at com.TestAutomation.TestRunner.TestRunner.runScenario(TestRunner.java:38) Caused by: java.net.ConnectException: Connection refused: connect
I want to fill a html form on a website with my small java program using PhantomJS. It is tested on my Win 10 machine and works perfectly. I would also like to run it on my OrangePiOne (Armbian 5.85 and Ubuntu 18.04.2). Every time I run the program I get the following exception:
Oct 10, 2019 10:24:07 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: executable: /home/ma/java_crontab_apps/phantomjs
Oct 10, 2019 10:24:07 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: port: 11594
Oct 10, 2019 10:24:07 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: arguments: [--webdriver=11594, --webdriver-logfile=/home/ma/java_crontab_apps/phantomjsdriver.log]
Oct 10, 2019 10:24:07 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: environment: {}
/home/ma/java_crontab_apps/phantomjs: 2: /home/ma/java_crontab_apps/phantomjs: Syntax error: word unexpected (expecting ")")
ERROR 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: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'orangepione', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'arm', os.version: '4.19.38-sunxi', java.version: '11.0.2'
Driver info: driver.version: PhantomJSDriver
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: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'orangepione', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'arm', os.version: '4.19.38-sunxi', java.version: '11.0.2'
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.<init>(RemoteWebDriver.java:111)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:115)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:110)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:99)
at com.example.suche.PhantomJsFormFill.createDriver(PhantomJsFormFill.java:76)
at com.example.suche.PhantomJsFormFill.<init>(PhantomJsFormFill.java:32)
at com.example.suche.Suche.main(Suche.java:98)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'orangepione', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'arm', os.version: '4.19.38-sunxi', java.version: '11.0.2'
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)
... 16 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:11594/status] to be available after 20027 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:163)
... 18 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)
... 19 more
Caused by: java.util.concurrent.TimeoutException
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:204)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
... 20 more
In the following method I am setting up the driver but get the exception during the return statement:
private WebDriver createDriver(String phantomjsExeutableFilePath) {
Suche.log(":::phantomjs path: " + phantomjsExeutableFilePath);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setJavascriptEnabled(true);
capabilities.setCapability(PHANTOMJS_EXECUTABLE_PATH_PROPERTY, phantomjsExeutableFilePath);
return new PhantomJSDriver(capabilities); // Exception is thrown here
}
I have downloaded the PhantomJS lib from official site and also chmod'ed it.
Could it be the fault of OrangePiOne or am I missing something?
It worked when I used phantomjs build for rasberry pi instead the one from the official site.
This issue was solved with phantomjs-on-rasberrypi from https://github.com/fg2it/phantomjs-on-raspberry.
Stack Trace of the Exception
1477308809616 geckodriver INFO Listening on 127.0.0.1:11372
Oct 24, 2016 5:03:30 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
1477308810262 mozprofile::profile INFO Using profile path C:\Users\PC-4\AppData\Local\Temp\rust_mozprofile.ppHCF7hshpOY
1477308810264 geckodriver::marionette INFO Starting browser C:\Program Files (x86)\Mozilla Firefox\firefox.exe
1477308810268 geckodriver::marionette INFO Connecting to Marionette on localhost:55966
1477308811347 Marionette INFO Listening on port 55966
1477308813944 Marionette INFO startBrowser 09e1e5f6-dc4a-4dcb-a2ad-783499097077
Oct 24, 2016 5:03:34 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
[Child 7676] ###!!! ABORT: Aborting on channel error.: file c:/builds/moz2_slave/m-rel-w32-00000000000000000000/build/src/ipc/glue/MessageChannel.cpp, line 2052
Exception in thread "main" org.openqa.selenium.WebDriverException: Failed to decode response from marionette
Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700'
System info: host: 'Sheetal', ip: '192.168.1.16', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_40'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, firefoxOptions={args=[], prefs={}}, appBuildId=20161019084923, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=7960, browserVersion=49.0.2, platformVersion=6.3, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt, device=desktop}]
Session ID: 09e1e5f6-dc4a-4dcb-a2ad-783499097077
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:322)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteNavigation.to(RemoteWebDriver.java:902)
at webdriverdemo.main(webdriverdemo.java:18)
Try this code:-
String currentDir = System.getProperty("user.dir");
String marionetteDriverLocation = currentDir +"/tools/marionette/wires.exe";
System.setProperty("webdriver.gecko.driver", marionetteDriverLocation);
WebDriver driver = new MarionetteDriver();
Change the name of geckodriver to wires.exe
I am getting the following error when I run this code in my automation suite,
Selenium 2.47.1
Internet Explorer 11
OS: Windows 8
WebDriver driver = new InternetExplorerDriver();
Exception Trace:
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.47.1',
revision: 'unknown', time: '2015-07-30 11:02:44' System info: host:
os.name: 'Windows 8', os.arch: 'amd64', os.version: '6.2',
java.version: '1.7.0_51' Driver info: driver.version:
InternetExplorerDriver at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:589)
at
org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
at
org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:227)
at
org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:182)
at
org.openqa.selenium.ie.InternetExplorerDriver.(InternetExplorerDriver.java:174)
at
org.openqa.selenium.ie.InternetExplorerDriver.(InternetExplorerDriver.java:146)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting
for driver server to start. Build info: version: '2.47.1', revision:
'unknown', time: '2015-07-30 11:02:44' System info: host: os.name:
'Windows 8', os.arch: 'amd64', os.version: '6.2', java.version:
'1.7.0_51' Driver info: driver.version: InternetExplorerDriver at
org.openqa.selenium.remote.service.DriverService.start(DriverService.java:170)
at
org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:63)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:568)
at
org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
at
org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:227)
at
org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:182)
at
org.openqa.selenium.ie.InternetExplorerDriver.(InternetExplorerDriver.java:174)
at
org.openqa.selenium.ie.InternetExplorerDriver.(InternetExplorerDriver.java:146)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed
out waiting for [http://localhost:23905/status] to be available after
20005 ms at
org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
at
org.openqa.selenium.remote.service.DriverService.start(DriverService.java:167)
... 50 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)
... 51 more Caused by: java.util.concurrent.TimeoutException at
java.util.concurrent.FutureTask.get(FutureTask.java:201) at
com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
... 52 more
I solved the problem by configuring the system property for the internet explorer driver,
System.setProperty("webdriver.ie.driver", "IEDriverServer.exe");
And changed the protected mode setting to be same for all the zones.
I'm having issues starting up the PhantomJS driver. It works just fine on my local machine (OSX) but I'm having issues getting it started on the server (Linux).
Here's the code that causes the issue:
DesiredCapabilities dcap = new DesiredCapabilities();
String[] phantomArgs = new String[] { "--webdriver-loglevel=NONE" };
dcap.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, phantomArgs);
dcap.setCapability("phantomjs.binary.path", "/usr/local/bin/phantomjs");
WebDriver driver = new PhantomJSDriver(dcap);
And here's the stack trace of the issue:
[ERROR] [09/09/2015 18:32:45.517] [pipeline-akka.actor.default-dispatcher-11] [akka://pipeline/user/$u] Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: os.name: 'Linux', os.arch: 'amd64', os.version: '3.14.48-33.39.amzn1.x86_64', java.version: '1.8.0_60'
Driver info: driver.version: PhantomJSDriver
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: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: os.name: 'Linux', os.arch: 'amd64', os.version: '3.14.48-33.39.amzn1.x86_64', java.version: '1.8.0_60'
Driver info: driver.version: PhantomJSDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:589)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:110)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:99)
at com.example.p.Test.ingest(GoogleGetLinksPipe.java:48)
at com.example.p.Test.ingest(GoogleGetLinksPipe.java:22)
at com.example.p.AbstractPipe.onReceive(AbstractPipe.java:39)
at akka.actor.UntypedActor$$anonfun$receive$1.applyOrElse(UntypedActor.scala:167)
at akka.actor.Actor$class.aroundReceive(Actor.scala:467)
at akka.actor.UntypedActor.aroundReceive(UntypedActor.scala:97)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
at akka.actor.ActorCell.invoke(ActorCell.scala:487)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238)
at akka.dispatch.Mailbox.run(Mailbox.scala:220)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: os.name: 'Linux', os.arch: 'amd64', os.version: '3.14.48-33.39.amzn1.x86_64', java.version: '1.8.0_60'
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:568)
... 20 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:8092/status] to be available after 20000 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:163)
... 22 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)
... 23 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)
... 24 more
I built the PhantomJS from source and had it working before - it ran through the tests just fine. Additionally, it works locally on my machine. Any thoughts on what could be causing the issue?
The problem was due to the phantomjs's inability to write to the log file. Changing the file permissions of the log file resolved the issue.