Error: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms.
Before all scripts were working fine..but now every script has stopped working.
I have updated Selenium version 3.0.1.(updated jar files), updated Firefox version 52.0.2 ...java version 8.
Please suggest what I am missing?
with Geckodriver version v0.15 , you have to use selenium 3.3.1
You would need to provide firefox binary location. One way of doing it is by the below code -
FirefoxOptions options = new FirefoxOptions();
options.setBinary("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); //Location where Firefox is installed
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("moz:firefoxOptions", options);
FirefoxDriver driver = new FirefoxDriver(capabilities);
driver.get("http://www.google.com");
More info here - http://www.automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/
For Selenium 2.x later versions need to maintain geckodriver for firefox browser and if you find same issue then add binary path to your driver instance and try again.
Reference:
selenium 2.53.0 with firefox 46
Related
Selenium: 3.141.59;
Chromium Edge: Version 87.0.664.41 (Official build) (64-bit);
hub runs on linux, nodes on Windows 10.
I Would like to set up the RemoteWebDriver with Chromium Edge version 87. I have tried various options, and I am currently most successful with:
ChromeOptions options = new ChromeOptions();
options.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe");
EdgeOptions edgeOptions = new EdgeOptions().merge(options);
RemoteWebDriver drv = new RemoteWebDriver(new URL(globalSetting.getHubUrl()),
edgeOptions);
drv.get("http://www.google.com");
With this the edge browser starts, but is unable to connect to the google url, because it is stuck in RemoteDriver setup. After some time, I get the a timeout and the message: WebDriverException: unknown error: unrecognized Chrome version: Edg/87.0.664.41
[With Chrome (google) it works fine.]
I red somewhere that this merge is not working with newer Chromium Edge and EdgeOptions should be used instead. But I only found Python code and it uses a field which EdgeOption in Java does not have (options.useChromium = true).
Has anybody been successful with Chromium Edge 86/87 and RemoteWebDriver in Java? If so could you provide a code example?
Chrome is not stable on my Jenkins. When I run build 5 times, it runs 1 - 2-time success, and the other 3 times I have the above error.
Snapshot of the error:
Code for Chrome :
ChromeOptions options = new ChromeOptions();
System.setProperty("webdriver.chrome.driver","/usr/local/bin/chromedriver");
options.addArguments("--headless");
options.addArguments("--no-sandbox");
options.addArguments("--disable-dev-shm-usage");
driver = new ChromeDriver(options);
driver.get("https://mywebsite.com");
Some steps I have already taken :
Provided 777 permission to google chrome and chrome driver
Set : Start Xvfb before the build, and shut it down after to True in Jenkins build setting
ChromeDriver 81.0.4044.69
Google Chrome 81.0.4044.129
Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-99-generic x86_64)
This error message...
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
Deep dive
Looking into the snapshot of the error stacktrace you have provided, though you mentioned about using ChromeDriver 81.0.4044.69 and Google Chrome 81.0.4044.129, still it appears there is a mismatch between the versions of the different binaries you are using, possibly Chrome browser is not installed at the default location within your system or due to JDK mismatch. Additionally, ChromeDriver 81.0.4044.69 (2020-03-17) was a bit unstable which was replaced by ChromeDriver 81.0.4044.138 (2020-05-05)
However, the server i.e. ChromeDriver expects you to have Chrome installed in the default location for each system as per the image below:
1For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary.
You can find a detailed discussion in What is default location of ChromeDriver and for installing Chrome on Windows
Solution
In case you are using the Chrome executable in a non-standard location you have to override the Chrome binary location as follows:
Code based solution:
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
ChromeOptions options = new ChromeOptions();
options.setBinary('/usr/bin/google-chrome'); //chrome binary location
options.addArguments("--headless");
options.addArguments("--no-sandbox");
options.addArguments("--disable-dev-shm-usage");
WebDriver driver = new ChromeDriver(options);
driver.get("https://www.google.com/");
//execute the remaining steps
driver.quit();
Additional considerations- Ensure the following:
JDK is upgraded to current levels JDK 8u251.
Selenium is upgraded to current levels Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v81.0.4044.138 level.
Chrome is updated to current Chrome Version 81.0.4044.138 level. (as per ChromeDriver v80.0 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Execute your #Test as non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
References
You can find a couple of relevant discussions in:
WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser
How to configure ChromeDriver to initiate Chrome browser in Headless mode through Selenium?
Running Chromedriver on Ubuntu Server headlessly
Recently I have migrated my automation scripts from selenium 2.53 to 3.3.1 version, and we could not able to run scripts in Firefox version due to below exception. i m using Firefox 50.1.0 and gecko v0.15.0
Exception in: TS_Testorg.openqa.selenium.SessionNotCreatedException: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
You would need to provide firefox binary location. One way of doing it is by the below code -
FirefoxOptions ffOptions = new FirefoxOptions();
options.setBinary("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); //Location where Firefox is installed
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("moz:firefoxOptions", options);
FirefoxDriver driver = new FirefoxDriver(capabilities);
driver.get("http://www.google.com");
More info here - http://www.automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/
For ex my chrome when dropped in the commpand prompt gives me the path
- /Applications/Google\ Chrome.app
I set
System.setProperty("webdriver.chrome.driver", "/Applications/Google/Chrome.app");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
But it doesnt work, same with firefox. I used a lot of suggestions already given but none seems to work. Can someone pls let me know if there is something to be added?
Why have you used "/Applications/Google/Chrome.app". You would need to provide the path of the driver only, not the browser. Below is the code for Firefox, but you would need to download and configure GeckoDriver (for latest version of FF and Selenium 3.x)
public class FirefoxTest {
#Test
public void FirefoxTest_Test1() {
System.setProperty("webdriver.gecko.driver","D:\\Firefox\\geckodriver.exe");
FirefoxDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
}
}
Check this link for complete details for downloading and setup of Geckodriver with Firefox - http://automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/
For Chrome: Need to Download fresh Chrome Driver from http://chromedriver.storage.googleapis.com/index.html?path=2.24/
and mention local system path up to chomedriver.exe
System.setProperty("webdriver.chrome.driver","G:\\ravik\\Ravi-Training\\Selenium\\Drivers\\cd\\chromedriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
ChromeDriver d1 = new ChromeDriver(capabilities);
For FF: if your firefox version is latest(46.0 or above) then user geckodriver along with selenium 2.53.0 jar files. download geckodriver form https://github.com/mozilla/geckodriver/releases and then save it as "wires" in your local system. mention local system path up to wires.
System.setProperty("webdriver.gecko.driver", "G:\\ravik\\Ravi-Training\\Selenium\\Marionette for firefox\\wires.exe");
WebDriver driver = new MarionetteDriver();
Hope this could be helpful.
The easiest way to use chrome driver is.. download and place the driver into the bin folder of your project. no need to set the path of the driver location
I have been trying to use selenium webdriver in my java code but it is not opening any url instead it is just opening a blank page. I am using selenium webdriver version 2.48 and firefox version 45.1.0 . I tried installing previous versin of firefox to my redhat but it is not working and giving error
" libgio-2.0.so.0: cannot open shared object file: No such file or directory
Couldn't load XPCOM."
My java code :
FirefoxProfile prof = new FirefoxProfile();
prof.setPreference("browser.startup.homepage_override.mstone", "ignore");
prof.setPreference("startup.homepage_welcome_url.additional", "about:blank");
WebDriver driver = new FirefoxDriver(prof);
// TestUtils
//.createCrawlDriverForTest(createDefaultCapabilities())
driver.get("https://www.google.com/");
Actually selenium 2.48 supports upto firefox version 41 so either i had to update the selenium webdriver version or use an older version of firefox.
using an older version did the trick for me.