I'm using Selenium with GhostDriver and PhantomJS to take a screenshot of Webpages from a Java Webapp.
I'm not sure why I'm getting this error. I suspect that the PhantomJSDriver is using the public ip of the server and maybe the firewall is not happy with that...
The project is working without any problem on my local machine (OSX) but not on the server (Debian 7).
2014-10-02 12:29:49,089 [ajp-8009-3] ERROR HibernateFilter - exception caught in hibernate filter for request
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.42.2', revision: '6a6995d31c7c56c340d6f45a76976d43506cd6cc', time: '2014-06-03 10:52:47'
System info: host: 'debian', ip: '8.8.8.8', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-028stab093.2', java.version: '1.6.0_
31'
Driver info: driver.version: PhantomJSDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:593)
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 org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:89)
at ...
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.42.2', revision: '6a6995d31c7c56c340d6f45a76976d43506cd6cc', time: '2014-06-03 10:52:47'
System info: host: 'debina', ip: '8.8.8.8', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-028stab093.2', java.version: '1.6.0_31'
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:572)
... 36 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:14083/status] to be available after 20007 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:163)
... 38 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)
... 39 more
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:258)
at java.util.concurrent.FutureTask.get(FutureTask.java:119)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
... 40 more
EDIT
I found that host and ip from the UnreachableBrowserException are coming from InetAddress.getLocalHost().getHostAddress() and InetAddress.getLocalHost().getHostName().
The timeout is actually coming from the localhost address Timed out waiting for [http://localhost:12518/status] to be available after 20010 ms.
I had a similar problem but it had nothing to do with a timeout even though the message was close. In fact it was caused by the fact that ghost driver could not create its log file.
Check if you have this message before in your logs and if so, try to change permissions just to check.
Related
I want to run my selenium/java scripts on safari browser.
Local runs work fine (Im able to see safari launch & scripts work fine).
But I am facing an issue when I try to run it through Jenkins. It errors out at this statement , does not launch safariBrowser driver = new SafariDriver(options);
Please note, Im able to run the scripts fine, when I login to the VM, and try to run on the VM. But when the scripts are triggered through Jenkins, it errors out.
This is my code :
SafariOptions options = new SafariOptions();
options.setCapability(CapabilityType.SUPPORTS_JAVASCRIPT, "true");
driver = new SafariDriver(options);
Error thrown :
org.openqa.selenium.WebDriverException:
java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9504
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'mac10-14-886479', ip: '10.0.10.253', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '1.8.0_181'
Driver info: driver.version: SafariDriver
Caused by: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9504
Caused by: java.net.ConnectException: Connection refused (Connection refused)
Other alternative tried :
Tried to check in other stackoverFlow posts.
I found few posts which says to launch safariDriver using automator script. But when I try to launch a safariDriver using automator script, I can see a "safariDriver" process started in the "activity monitor", But when my scripts run, there's no way to hook up to the same port, and use the already running safariDriver
This is the automator script that was used :
security unlock-keychain -p '<password>'
/usr/bin/safaridriver --enable
/usr/bin/safaridriver --port 7050
Any help on this is much appreciated !
This error message...
org.openqa.selenium.WebDriverException:
java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9504
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'mac10-14-886479', ip: '10.0.10.253', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '1.8.0_181'
Driver info: driver.version: SafariDriver
Caused by: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9504
Caused by: java.net.ConnectException: Connection refused (Connection refused)
...implies that the WebDriver was unable to communicate with the Browsing Context i.e. Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using java.version: '1.8.0_181'
But you are using Selenium version: '3.12.0' of 2018-05-08T14:04:26.12Z which is old and ancient.
Solution
Ensure that:
Selenium is upgraded to current released Version 3.141.59.
Hi I apologise for a repost but I am new to selenium and tried to launch this simple command to open youtube in a google. However, it keeps crashing and showing this error. Directly below is the code I am running.
System.setProperty("webdriver.chrome.driver",
"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
System.out.println(System.getProperty("webdriver.chrome.driver"));
WebDriver driver3 = new ChromeDriver();
driver3.get("https://www.youtube.com/");
Could anyone point me in the right direction of where I'm going wrong. Thank you
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
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: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'nuigit450', ip: '192.168.16.22', os.name: 'Windows
7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_111'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:622)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:141)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:174)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:163)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:120)
at TestWeb.main(TestWeb.java:22)
Caused by: java.lang.IllegalStateException: The process has not exited yet therefore no result is available ...
at org.apache.commons.exec.DefaultExecuteResultHandler.getException(DefaultExecuteResultHandler.java:76)
at org.openqa.selenium.os.UnixProcess.checkForError(UnixProcess.java:173)
at org.openqa.selenium.os.CommandLine.checkForError(CommandLine.java:185)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:177)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:166)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
... 7 more
Your webdriver.chrome.driver point to Chrome browser but it should point to chromedriver. For reference: https://sites.google.com/a/chromium.org/chromedriver/getting-started
You need to download chromedriver from here: https://sites.google.com/a/chromium.org/chromedriver/downloads and set path to this file in webdriver.chrome.driver.
I am getting the below error from today when I run my test suite. I am using chrome driver since our Application runs only on chrome. The same scripts are running fine in another machine.
Starting ChromeDriver 2.12.301325 (962dea43ddd90e7e4224a03fa3c36a421281abb7) on port 37280
Only local connections are allowed.
Nov 12, 2014 11:33:36 AM org.openqa.selenium.os.UnixProcess$SeleniumWatchDog destroyHarder
INFO: Command failed to close cleanly. Destroying forcefully (v2).org.openqa.selenium.os.UnixProcess$SeleniumWatchDog#1c06d198
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.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'MyTerminal', ip: '10.54.205.137', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_51'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:589)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.chrome.ChromeDriver.startSession(ChromeDriver.java:181)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:160)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:128)
at ChromeTest.main(ChromeTest.java:14)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'MyTerminal', ip: '10.54.205.137', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_51'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:165)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:62)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:568)
... 7 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:37280/status] to be available after 20001 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:163)
... 9 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)
... 10 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)
... 11 more
I have used following trouble shooting steps.
1. Tried disabling the gpu-watchdog in chrome
2. Re-Installed Chrome
3. Re-cloned all my project from git hub
4. Installed older version.
I don't have luck to run this. Can some one point me in right direction If I am missing something here.
My concern is these scripts ran till yesterday and suddenly I am getting this error.
Thanks in Advance.
After running out all possible options, At last I found a little solution for this. I played a trick with the chrome driver versions, But not sure why and how it worked. I have followed these steps
I have downloaded the latest version of chrome driver and ran my
selenium tests by configuring System.setProperty()
Now I double clicked the old chrome driver version (which I have used it for my
script earlier) while running my selenium script.
Then I configured my script back to my old version.
That's it my scripts are running smooth without any exceptions. :-)
I'm very new to Selenium. Below given is my first test script.
Question: Does it require selenium server to test a local website (which is hosted in the same machine as the test scripts being run).
Also tried executing the same script from Internet Explorer also, still getting the same.
It just opens the browser and closes(because of finally block) it.
import org.openqa.selenium.chrome.ChromeDriver;
public class TestScript {
/**
* #param args
* #throws InterruptedException
*/
public static void main(String[] args) {
ChromeDriver driver = null;
try
{
System.setProperty("webdriver.chrome.driver", "C:\\Users\\user1\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");
driver = new ChromeDriver();
System.out.println("Opening the Browser");
driver.get("http://localhsot:5080/myWebSite/8450191#");
System.out.println("Open the Browser");
System.out.println("");
System.out.println("Title" +driver.getTitle());
}
catch (Exception ie)
{
ie.printStackTrace();
}
finally
{
System.out.println("Quitting the Browser");
driver.close();
driver.quit();
}
}
}
Exception: Below is the exception I am getting while executing from the Eclipse:
[2820:6204:36503609:ERROR:gpu_info_collector_win.cc(93)] Can't retrieve a valid WinSAT assessment.
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: 'ff23eac', time: '2013-12-16 16:12:12'
System info: host: '01hw535163', ip: '10.72.15.53', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_17'
Driver info: driver.version: ChromeDriver
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:112)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:116)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:162)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:108)
at com.seic.scripts.TestScript.main(TestScript.java:16)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
System info: host: '01hw535163', ip: '10.72.15.53', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_17'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:165)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:62)
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:37571/status] to be available after 20009 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$Sync.innerGet(FutureTask.java:228)
at java.util.concurrent.FutureTask.get(FutureTask.java:91)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
... 10 more
Quitting the Browser
Exception in thread "Main Thread" java.lang.NullPointerException
at com.scripts.TestScript.main(TestScript.java:31)
Chrome Version: 21.0.1171.0
OS: Windows 7 64 bit.
Selenium Web Driver version:2.39.0
You are getting a little confused about what you need to point Selenium to.
Here:
System.setProperty("webdriver.chrome.driver", "C:\\Users\\user1\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");
This setting, webdriver.chrome.driver is a setting that Selenium will read to find out where the ChromeDriver is located, not the actual Chrome installation.
https://code.google.com/p/selenium/wiki/ChromeDriver
You must download the ChromeDriver and where it is located should be what you pass in for the webdriver.chrome.driver property.
I imagine it's the same reason when you try with IE, it also requires a driver which I guess you don't have:
https://code.google.com/p/selenium/wiki/InternetExplorerDriver
In terms of whether you need a "server" -> for your tests, no, you are not running them remotely. Once you decide to run them remotely (i.e use the RemoteWebDriver instead of ChromeDriver) then you will need the Selenium server.
I would recommend instead of using System.setProperty() to put your drivers in the same folder and point to that folder in System Variables Path. Then you don't need to point to it at all in code and updating your driver won't require a code rewrite.
I have an application that uses Selenium Webdriver to get some information from a site. It works fine with FirefoxDriver and ChromeDriver, but when I tried to switch to PhantomJSDriver, I encountered some difficulties.
On a Windows machine , it starts normally, then immediately begins spitting out the following lines over and over again:
Jan 05, 2014 7:28:43 PM org.apache.http.impl.client.DefaultRequestDirector tryEx
ecute
INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request: The target server failed to respond
This is repeated probably several hundred times for about 10 minutes until it finally loads the page; sometimes it doesn't even manage to load it at all.
On a Linux machine, it tries to start, then returns the following:
Exception in thread "thread1"
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: 'pangolin',
ip: '128.238.32.20', os.name: 'Linux', os.arch: 'amd64', os.version:
'2.6.32-39-generic', java.version: '1.7.0' 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:107)
at org.openqa.selenium.phantomjs.PhantomJSDriver.(PhantomJSDriver.java:96)
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: 'pangolin', ip: '128.238.32.20',
os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-39-generic',
java.version: '1.7.0' Driver info: driver.version: PhantomJSDriver
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:165)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:62)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527)
... 7 more Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting
for [http://localhost:16050/status] to be available after 20002 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:163)
... 9 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)
... 10 more Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:258)
at java.util.concurrent.FutureTask.get(FutureTask.java:119)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
... 11 more
What am I doing wrong? I've read a lot about how Phantomjs is so much faster than the other drivers, and would really like to use it, but if it takes 10 minutes to load each page, that's obviously not feasible.
I am running Selenium WebDriver version 2.38.0 and Phantomjs version 1.9.2.
Thank you very much in advance,
bsg
EDIT
Just to clarify, I don't think this has anything to do with my code; the errors on Linux are being thrown on the line where I try to start the PhantomJS driver, below.
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability(
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
phantombinary//"/home/p/phantomjs-1.9.2-linux-x86_64/bin/phantomjs"
);
// Launch driver (will take care and ownership of the phantomjs process)
WebDriver driver = new PhantomJSDriver(caps);
System.out.println("starting driver");
If it is still not working for you on Linux, try below piece of code, it is working for me on Mac.
capabilities.setCapability("phantomjs.binary.path", "path of phantom binary/phantomjs")
org.openqa.selenium.remote.UnreachableBrowserException clearly something to do with Phantom. On Windows ensure Phantom is running (Set Environment variable and add PATH)
Check that Remote Machine hub address is correct and you should be able to run phantomjs.
Note: Selenium Server must be running on the desired remote machine.
DesiredCapabilities phantomBeast = DesiredCapabilities.phantomjs();
try {
webDriverInstance = new RemoteWebDriver(new URL(hubUrl), phantomBeast);
} catch (Exception e) {
//Do something
}