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?
Related
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
Google Chrome 75.0.3770.80 is installed on Docker image on CentOS 7
Chrome driver 75.0.3770.80 is checked-in with the framework
And docker container shows the correct version for both chrome browser and chrome driver, means both are installed successfully.
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + File.separator+"path/chromedriver");
ChromeOptions options = new ChromeOptions();
options.addArguments("--no-sandbox");
options.addArguments("--headless");
options.setExperimentalOption("useAutomationExtension", false);
options.addArguments("disable-infobars"); // disabling infobars
options.addArguments("--disable-extensions"); // disabling extensions
options.addArguments("--disable-gpu"); // applicable to windows os only
options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
DesiredCapabilities chromeCapabilities = DesiredCapabilities.chrome();
options.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
options.merge(chromeCapabilities);
driver = new ChromeDriver(options);
Xvfb is set on Container and shows below output:
DISPLAY=:99
root 33 13 0 05:42 ? 00:00:00 Xvfb :99 -screen 0 1920x1920x24
When i try to launch the Chrome browser, it shows
unknown error: DevToolsActivePort file doesn't exist
You can see that the code above has all the options added.
I referred stackoverflow already answered here, but that doesn't seems to be working
WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser
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/
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
I'm trying to run my Java selenium tests using Opera (version 31). I'm using last version of Selenium Webdriver (2.47.1) and last version of OperaChromiumDriver (0.2.2).
I've tried to use next method to instantiate Opera:
System.setProperty("webdriver.chrome.driver", "\\path\\to\\my\\operadriver.exe");
WebDriver driver = new ChromeDriver();
And i've tried another method with RemoteWebdriver:
DesiredCapabilities capabilities = DesiredCapabilities.opera();
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/opera");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new RemoteWebDriver(new URL("http://127.0.0.1:9515"),capabilities);
(these methods are described in answers to this question: How to use OperaChromiumDriver for opera version >12.X)
Both methods have the same problem.
Opera opens, but then crushes with next exception:
org.openqa.selenium.SessionNotCreatedException: session not created exception from disconnected: Unable to receive message from renderer
(Session info: Opera with embedded Chromium 0.1889.230)
(Driver info: OperaDriver=0.2.0 (ba47709ed9e35ce26dbd960fb5d75be104290d96),platform=Windows NT 6.1 x86_64
(WARNING: The server did not provide any stacktrace information)
Firefox, Chrome and IE drivers work as it should be, i have such problem only with OperaChromiumDriver.
Can anyone help me with this issue?
Try to instantiate OperaDriver like this instead:
File operaFile = new File("\\path\\to\\my\\operadriver.exe");
System.setProperty("webdriver.opera.driver", operaFile.getAbsolutePath());
WebDriver driver = new OperaDriver();
In my application, .getAbsolutePath() works but just specifying the path in .setProperty does not. No idea why, since the string output of either is identical.
Unfortunately I am still unable to use OperaDriver in my tests because it becomes unresponsive after loading a few pages. This occurs on 3 different machines running different versions of Windows and returns only this error:
[SEVERE]: Timed out receiving message from renderer:
FirefoxDriver, ChromeDriver, and InternetExplorerDriver all work fine with my tests, so, whatever.