I am having some difficulties with Selenium opening Firefox. It works on my computer at home but I am not sure why it doesnt work on my work computer. Some help and guidance on this would be much appreciated because I am newbie to this tool and eclipse.
I have downloaded geckodriver 10 and am running Selenium 3 with Eclipse Neon. I imported the selenium-server-standalone-3.0.0-beta3 to the Java Build Path to my test Selenium project.
My code is as follows:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class openBrowser {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "D:\\JW\\Selenium\\geckodriver-v0.8.0-win32\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.com");
}
}
When I run the program I get the following in the console:
Sep 30, 2016 10:42:18 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
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: '3.0.0-beta3', revision: 'c7b525d', time: '2016-09-01 14:57:03 -0700'
System info: host: 'SBC-40489825', ip: '10.27.20.46', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_73'
I run the program but firefox never seems to open as the connection seems to be refused Any ideas whats wrong?
Best Regards
Tarquin
Try Marrionatedriver, it will use. Following is the code:
WebDriver driver = new MarrionateDriver();
I would suggest you don't use beta version until a final stable version of Selenium3 is not being released there may have many bugs which would be fix.
You should downgrade your selenium version to last stable version of Selenium2.
Because Selenium2 works well without using GeckoDriver to lunch Mozilla Firefox < v47, you should downgrade it as well below v47 to get rid from these issues until final version of Selenium3 is not being released.
This works
System.setProperty("webdriver.firefox.marionette",D:\\JW\\Selenium\\geckodriver-v0.8.0-win32\\geckodriver.exe);
This issue is specific to Geckodriver Windows32 bit.
GeckoDriver doesn't support Windows 32Bit, they are yet to release Geckodriver V0.11 version. You check version Milestone status
You can also check the discussion on this issue here last comments
Here is an article that explains this issue.
UPDATE : Geckodriver V0.11 version released. Please try use this version.
Related
The following code works without any problem when running from Eclipse:
System.setProperty("webdriver.gecko.driver", pathToGeckoDriver);
FirefoxOptions options = new FirefoxOptions();
options.setHeadless(true);
WebDriver driver = new FirefoxDriver(options);
driver.manage().window().setSize(new Dimension(2500, 1500));
driver.get(myUrl);
driver.close();
But fail when running within a Docker Container with the following error:
The driver server has unexpectedly died!
Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:24:21.231Z'
System info: host: 'XXXX', ip: 'XXX.X.X.X', os.name: 'Linux', os.arch:'amd64', os.version: '3.10.0-862.9.1.el7.x86_64', java.version: '1.8.0_73'
Driver info: driver.version: RemoteWebDriver
I'v read that it might come from incompatibility between the Selenium framewrok and the Firefox version. I'm using the following Selenium Framework:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.14.0</version>
</dependency>
And Firefox has been newly installed on both environment with the latest version.
I'm running out of ideas ... does anyone have any pointer/ideas?
This error message...
The driver server has unexpectedly died!
...implies that the GeckoDriver was unable to initiate/spawn a new WebBrowser i.e. Firefox Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
As per the error logs your Selenium Client version is 3.13.0 but as per the Maven configuration your Selenium Client version is 3.14.0
Your JDK version is 1.8.0_73 which is pretty ancient.
Your GeckoDriver version is unknown to us.
Your Firefox version is unknown to us.
So there is a clear mismatch between the JDK v8u73 , Selenium Client v3.13.0.
Solution
Upgrade JDK to recent levels JDK 8u181.
Upgrade Selenium to current levels Version 3.14.0.
Upgrade GeckoDriver to GeckoDriver v0.20.1 level.
Upgrade Firefox version to Firefox v61.0.2 levels.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
(LinuxOS only) Free Up and Release the Unused/Cached Memory in Ubuntu/Linux Mint before and after the execution of your Test Suite.
If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your Test as a non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
System.setProperty("webdriver.chrome.driver","D:/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.navigate().to("https://link");
driver.findElement(By.cssSelector("#username")).sendKeys("id");
driver.findElement(By.cssSelector("#password")).sendKeys("pass");
driver.findElement(By.cssSelector("#clientName")).sendKeys("name");
driver.findElement(By.cssSelector("#submitButton")).click();
System.out.println("Okay !");
I set property for Chrome Driver. When I run it gives an error. (Below) I searched a lot but didn't found any solution.
Starting ChromeDriver 2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab) on port 10589
Only local connections are allowed.
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: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:03.216Z'
System info: host: 'DESKTOP-9HVORCR', ip: '192.168.1.24', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_171'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:564)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:207)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
at zaaa.main.main(main.java:11)
Caused by: java.lang.IllegalArgumentException: Unexpected char 0x131 at 23 in User-Agent value: selenium/3.12.0 (java wındows)
at okhttp3.Headers$Builder.checkNameAndValue(Headers.java:338)
at okhttp3.Headers$Builder.add(Headers.java:288)
at okhttp3.Request$Builder.addHeader(Request.java:177)
at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:85)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:101)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
... 6 more
I have tried these:
32/64 bit drivers.
Run it as administrator.
Creating a Try/Catch block.
Other drivers. (Like Operadriver.exe) (Result: Same error)
I think your windows is not english. I am having the same problem. When I tried the same in an english version windows 10 the code works without any problem.
Locale.setDefault(new Locale("en", "EN"));
you can also try this. it worked for me.
Add these lines before instantiating "WebDriver driver = new ChromeDriver();"
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--no-sandbox");
Then add the argument where you have declared Webdriver as shown below:-
WebDriver driver = new ChromeDriver(chromeOptions);
I hope it will help you.
Here you are using
selenium version : 3.12.0
chromedriver version : 2.40
When i tried to run with these configurations (they are latest at present)
I am able to launch the application without any exception and in the logs getting :
Starting ChromeDriver 2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab) on port 35584
Only local connections are allowed.
Jun 21, 2018 2:42:51 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Okay !
which is same as your starting logs.
My chrome browser version is :
Version 67.0.3396.87 (Official Build) (64-bit)
I think you should check your .m2 folder and delete
.m2\repository\org\seleniumhq\selenium
folder from there and then again try to download the dependencies.
Also update to latest chrome browser version.
Hope it helps.
This is a problem of Turkish Windows. As it is indicated in exception message the 'ı' character in user agent value "selenium/3.12.0 (java wındows)" is the cause of the exception.
The problem is the string "WINDOWS" is changed to lower case and it results "wındows" because of TR locale. I found that it is generated in class org.openqa.selenium.remote.http.HttpClientand added Locale.US like this.
String USER_AGENT = String.format(
"selenium/%s (java %s)",
new BuildInfo().getReleaseLabel(),
(Platform.getCurrent().family() == null ?
Platform.getCurrent().toString().toLowerCase(Locale.US) :
Platform.getCurrent().family().toString().toLowerCase(Locale.US)));
I compiled the library with my changes and it works now. I also opened a pull request on github.
You can also find my edited fork here.
When I run my tests on Chrome I often get a WebdriverException that Chrome is not reachable. It doesn't happen every time. Maybe once every 15 times. I am having to run everything on Windows machines and I have the latest Chrome, Chromedriver, Selenium-Webdriver versions.
I've tried setting the environmental variable "DBUS_SESSION_BUS_ADDRESS=/dev/null". Doesn't help at all.
Anyone come across this and found a solution?
org.openqa.selenium.WebDriverException: chrome not reachable
(Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 62.52 seconds
Build info: version: '2.52.0', revision: '4c2593cfc3689a7fcd7be52549167e5ccc93ad28', time: '2016-02-11 11:22:43'
System info: host: 'CORPMNA7158A', ip: '10.26.195.163', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_144'
Driver info: org.openqa.selenium.chrome.ChromeDriver
The error does gives us some hint as follows :
org.openqa.selenium.WebDriverException: chrome not reachable
Which essentially implies that chromedriver binary is unable to spawn a new Chrome Browser process.
Your main issue is the version compatibility among the binaries you are using as follows :
You are using chromedriver=2.35.528161 (released 2018-01-10)
Release Notes of chromedriver=2.35 clearly mentions the following :
Supports Chrome v62-64
You mentioned of using latest Chrome. I suppose it is chrome=65.x
You are using Selenium Version 2.52.0 (released 2016-02-11 11:22:43) [as per the error stack trace within your question]
So the time gap between the release of Selenium Version 2.52.0 and chromedriver=2.35.528161 is almost 2 Years and are not compatible. Hence ChromeDriver is unable to spawn the new Chrome Browser process at times.
Solution
Keep the ChromeDriver at v2.35 level.
Downgrade Chrome to stable Chrome v64.x levels. (as per ChromeDriver v2.35 release notes)
Upgrade Selenium to current levels Version 3.8.1.
Execute your Test.
I recently found that my Selenium Java libraries were not working. Version 2.48.2 would open a Firefox window and then "stall" with no error within Netbeans nor Firefox itself before returning from new FirefoxDriver(). I figured that this version of Selenium might be broken so I found the latest Java libraries (Version 2.53.1) and have been trying to get them to work.
My issue now is almost the same but with two errors. The first is thrown by Netbeans when trying to execute new FirefoxDriver().
Exception in thread "AWT-EventQueue-0" 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.53.1', revision: 'a36b8b1', time: '2016-06-30 17:32:46'
System info: host: 'MrComputer', ip: '192.168.0.101', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_65'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
...
The second is from Firefox itself. The window opens but instantly encounters the error.
Problem signature:
Problem Event Name: APPCRASH
Application Name: firefox.exe
Application Version: 47.0.0.5999
...
The code I am using is quite simple. Just the line
WebDriver driver = new FirefoxDriver();
I am by no means an extremely knowledgeable Selenium user so I am not sure what other information I could provide that might be of help.
EDIT: It seems that my Firefox version was not high enough to use the 2.53.1 Selenium libraries. My version of 47.0.0.5999 needed to be at least 47.0.1.
Prior to this, version 2.53.0 did need to make use of the MarionetteDriver as per this SO answer.
Unfortunately Selenium WebDriver 2.53.0 is not compatible with Firefox
47.0. The WebDriver component which handles Firefox browsers (FirefoxDriver) will be discontinued. As of version 3.0, Selenium
WebDriver will have MarionetteDriver as the default running
implementation for Firefox tests.
...
UPDATE
Selenium WebDriver 2.53.1 has been released on 30th June 2016.
FirefoxDriver is working again with Firefox 47.0.1 as browser.
For Selenium 2.53.1 the Firefox version needs to be at least 47.0.1. Updating my Firefox did the trick.
EDIT: It also seems that version 47.+ was not released to the Ubuntu archives for a few weeks after the Windows version.
I am using Selenium to test my website, it opens up a URL using Firefox, logins and does some stuff on the page and then logs out and shuts firefox. That all works great on Windows 7. The code starts with:
WebDriver driver = new FirefoxDriver();
driver.get(URL);
Now I deployed my jar in linux box that runs Debian lenny which has iceweasel on it. A cron job starts the program which throws the following error when trying to open firefox:
org.openqa.selenium.firefox.NotConnectedException: Unable to connect
to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Error: cannot open display: :0 Error: cannot open display: :0
at
org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:106)
at
org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:244)
at
org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:110)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:190)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:183)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:179)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:92)
at auth.Authenticator.authenticate(Authenticator.java:15) at
reader.ReaderThread.run(ReaderThread.java:67)
org.openqa.selenium.WebDriverException: Failed to connect to binary
FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows:
Error: cannot open display: :0 Error: cannot open display: :0
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: os.name: 'Linux', os.arch: 'i386', os.version:
'2.6.26-2-686', java.version: '1.6.0_26' Driver info: driver.version:
FirefoxDriver at
org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118)
at
org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:244)
at
org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:110)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:190)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:183)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:179)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:92)
at auth.Authenticator.authenticate(Authenticator.java:15) at
reader.ReaderThread.run(ReaderThread.java:67)
I have Xvfb running ok in the box and I have set variable DISPLAY to 0. I have searched around and none of the solutions (like setting the env variable) worked.
Isnt XVfb supposed to work as a non-graphical environment that the browser will launch into and do the necessary actions? What's stopping it from starting up?
I am using the latest Selenium version 2.31 and Firefox 3.0.6 Iceweasel.
Edit: Updated to Firefox 14 and still see the same issue. I even raised the timeout limit to 60 seconds.
driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);
SOLVED: By running it with the xvfb wrapper, xvfb-run like this:
export DISPLAY=:0.0
xvfb-run --auto-servernum --server-num=0 nohup java - jar X.jar
Solved by doing this:
export DISPLAY=:0.0 xvfb-run --auto-servernum --server-num=0 nohup java - jar X.jar
I have seen the similar issue and this is coming only for firefox, for other browser everything was working fine, I tried on Chrome.
Here is the solution for this
1. Check the version of FF, if it is latest, then go for a lesser version of FF. It is recommended for more stability.
2. And you should always try to take latest selenium binary from selenium website.
For more details try this solution:
http://khyatisehgal.wordpress.com/2014/09/09/at-org-openqa-selenium-firefox-internal-newprofileextensionconnection-startnewprofileextensionconnection-java106/
Either try to update your webdriver or downgrade your firefox.
this issue is related that selenium server cannot connect to your firefox.
This issue get resolved after upgraded to the latest Selenium jar.