i am trying to run the chrome beta version with selenium Web-driver.
When i run the test case i got the following error on console see image please:
I have added following lines in the node config file:
{
"capabilities": [
{
"platform": "WINDOWS",
"browserName": "chrome",
"webdriver.chrome.driver":"drive:\selenium\chromedriver.exe",
"chromeOptions": "drive:\Program Files (x86)\Google\Chrome Beta\Application\chrome.exe",
}
]
I am using following setup:
Selenium=2.53
chrome Web-driver= 80_0_3987_16
Google chrome= 80.0.3987.66 (Official Build) beta (64-bit)
we have Hub and Node setup and automated test suit executed from GO cicd Server.
any help would be appreciated, thanks
To run either of the google-chrome browser variant among:
Chrome Canary
Chrome from Dev Channel
Raw build of Chromium for Windows x64
You need to to download the latest Chromium binary from either of the official repositories:
The Chromium Projects
chromium.appspot
Chrome Canary - Nightly build for developers
and you can use the following solution:
Code Block:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class A_Chrome_Canary {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
ChromeOptions opt = new ChromeOptions();
opt.setBinary("C:\\Users\\AtechM_03\\AppData\\Local\\Google\\Chrome SxS\\Application\\chrome.exe");
WebDriver driver = new ChromeDriver(opt);
driver.get("https://www.google.com/");
System.out.println(driver.getTitle());
}
}
Console Output:
Google
Browser Snapshot:
This worked for me
chrome_options.binary_location = "C:/Program Files/Google/Chrome Beta/Application/chrome.exe"
Related
I'm trying to setup tests with NodeJS, Selenium & Jest. They work fine on my Mac but both a Windows and Linux install are failing with similar errors:
WITHOUT THE PATH EXPLICITLY SET
WebDriverError: unknown error: cannot find Chrome binary
at Object.throwDecodedError (node_modules/selenium-webdriver/lib/error.js:522:15)
at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:548:13)
at Executor.execute (node_modules/selenium-webdriver/lib/http.js:474:28)
WITH THE PATH EXPLICITLY SET
WebDriverError: unknown error: Chrome failed to start: exited
abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/local/bin/chromedriver is no longer running, so ChromeDriver is
assuming that Chrome has crashed.)
FWIW on a linux machine running chromedriver directly I get this:
Starting ChromeDriver 98.0.4758.80
(7f0488e8ba0d8e019187c6325a16c29d9b7f4989-refs/branch-heads/4758#{#972})
on port 9515 Only local connections are allowed. Please see
https://chromedriver.chromium.org/security-considerations for
suggestions on keeping ChromeDriver safe. ChromeDriver was started
successfully.
Setting the path directly has not worked, using a globally installed (/usr/local/bin/chromedriver) binary and a local one node_modules/chromedriver/bin/chromedriver). None of the following options has made any difference:
.addArguments([
"--ignore-certificate-errors",
"--disable-extensions",
"--disable-popup-blocking",
"--enable-automation",
"--disable-dev-shm-usage",
"--no-sandbox",
"--headless",
"--log-path=/home/jsp/projects/proj/selenium/chrome.log",
"--append-log",
"--verbose",
"--enable-chrome-logs",
"--port=9222"
])
Enabling logging generated an empty chrome.log file. I tried simplifying and this is what I ended up with that again works on my Mac but not on the Linux test box.
const { Builder } = require("selenium-webdriver");
const chrome = require("selenium-webdriver/chrome");
let chromeTest = async () => {
let options = new chrome.Options()
.setChromeBinaryPath('/usr/local/bin/chromedriver')
.addArguments(["headless", "ignore-certificate-errors", "disable-dev-shm-usage", "no-sandbox"]);
let driver = await new Builder()
.forBrowser("chrome")
.setChromeOptions(options)
.build();
await driver.quit();
};
chromeTest();
Selenium: 4.1.1
ChromeDriver: 98.0.4758.80
Ubuntu 20.04.3
Any help would be greatly appreciated.
I just rebuilt our development environment. This forced the latest version of chrome and suddenly the protractor based tests stopped working. After some research, I tracked this down to the fact that our chrome options in the protractor configuration file are now ignored.
Here is the configuration that used to work fine before:
exports.config = {
...
multiCapabilities : [
{
browserName: "chrome",
chromeOptions: {
args: [
"--disable-gpu",
"--headless",
'--no-sandbox',
"--incognito"
]
}
},
},
],
...
};
Before After
protractor 6.0.0 6.0.0
selenium 4.0.0-alpha-1 4.0.0-alpha-1
chrome 74.0.3729.157 76.0.3809.100
chromedriver 74.0.3729.6 76.0.3809.68
In recent versions of selenium you have to specify the chrome options as goog:chromeOptions. So just change the chromeOptions line above to the following:
...
"goog:chromeOptions": {
...
and you are back in business.
"chromeOptions": {}
its still usable in most cases, but does not support new arguments provided by chrome
suggested to use
"goog:chromeOptions": {}
Ref to doc: http://chromedriver.chromium.org/capabilities
Same rule for firefox
"moz:firefoxOptions": {}
Ref to doc: https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities/firefoxOptions
I am trying to run a simple selenium case on Ubuntu 16.4 to check my updated ChromeDriver version. Here is my settings information:
OS: Ubuntu 16.04
Chromium: 69.0.3497.81, Built on Ubuntu ,
Chromedriver: v2.8.240825
jdk: openjdk version "1.8.0_181"
And here is my simple java code:
public static void main(String[] args) throws IOException, InterruptedException {
System.setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver");
System.setProperty("webdriver.chrome.logfile", "/tmp/chromedriver.log");
System.setProperty("webdriver.chrome.verboseLogging", "true");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--headless", "window-size=1024,768", "--no-sandbox");
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get("https://google.com");
System.out.println("Title is " + driver.getTitle());
if (driver.getPageSource().contains("I'm Feeling Lucky")) {
System.out.println("Pass");
} else {
System.out.println("Fail");
}
driver.quit();
}
But during the runtime, I'm keep getting "Chrome failed to start: exited abnormally", with such in the log file:
"
....
[0.317][INFO]: Launching chrome: /usr/bin/chromium-browser --disable-background-networking --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-hang-monitor --disable-prompt-on-repost --dis
able-web-resources --enable-logging --full-memory-crash-report --ignore-certificate-errors --load-extension=/tmp/.org.chromium.Chromium.GO6lAd/internal --logging-level=1 --metrics-recording-only --no-first-run --password-store=basic --re
mote-debugging-port=12811 --safebrowsing-disable-auto-update --safebrowsing-disable-download-protection --use-mock-keychain --user-data-dir=/tmp/.org.chromium.Chromium.uTbJHO data:,
[0.317][DEBUG]: DevTools request: http://127.0.0.1:12811/json/version
[0.319][WARNING]: PAC support disabled because there is no system implementation
[0.390][DEBUG]: DevTools request failed
[0.440][DEBUG]: DevTools request: http://127.0.0.1:12811/json/version
[0.441][DEBUG]: DevTools request failed
"
But if I was to downgradethe the ChromeDriver to version 2.4, same code runs perfectly. Does anyone know why ? The reason why I need the latest one, is because there is some other feature I need to use.
The failure was actually with older Chrome-driver, of version 2.9, 2.8. etc. The very latest ones, 2.38, or 2.42 does not have such behavior.
I'm using Selenium server 3.8.1, with the hub and 2 nodes.
The hub and each node are executed on different machines.
Currently, I can launch the tests and they're working fine. But, I'm not able to make the headless mode run.
My config JSON only contains the capabilities object.
{
"capabilities":
[{
"browserName": "chrome",
"maxInstances": 3,
"seleniumProtocol": "WebDriver",
"chromeOptions": {
"args": [
"--headless",
"--disable-gpu",
"--window-size=1920x1080"]
}}]
}
I launch the selenium nodes using a .bat that contains the following command:
"C:\Program Files\Java\jre1.8.0_181\bin\java" -jar C:\jobs\selenium-node\selenium-server-standalone-3.8.1.jar -role node -hub http://172.16.0.5:5555/grid/register -port 5558 -nodeConfig config.json -maxSession 3
The selenium node works fine and appears on the selenium grid UI. Also, the capabilities of the chrome driver include the --headless and other parameters:
....
capabilities: Capabilities {browserName: chrome, chromeOptions: {args: [--headless, --disable-gpu, --window-size=1920x1080]}, maxInstances: 3, platform: XP, se:CONFIG_UUID: cdc21610-4c47-4d23-9478-a20..., seleniumProtocol: WebDriver}
....
On the protractor.conf file I have these capabilities, that work when I run the tests locally.
seleniumAddress:'http://172.16.0.5:5555/wd/hub',
getPageTimeout: 120000,
allScriptsTimeout: 120000,
ignoreUncaughtExceptions: true,
chromeOnly:true,
directConnect: false,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
"javascriptEnabled": true,
"acceptSslCerts": true,
"browserName": "chrome",
"chromeOptions": {
"args": [ "--headless", "--disable-gpu", "--window-size=1920,1080"]
}
},
But, when I launch the tests, the chrome driver isn't executed on headless mode. Works fine, but the different windows keep appearing.
Environment details:
chromedriver version: 2.36.540470
chrome version: 69.0.3497.100
As per your question/comment update you are using:
chromedriverVersion: '2.36.540470, chrome version' => '69.0.3497.100'
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.36
Release Notes of chromedriver=2.36 clearly mentions the following :
Supports Chrome v63-65
You are using chrome=69.0
Release Notes of ChromeDriver v2.42 clearly mentions the following :
Supports Chrome v68-70
So there is a clear mismatch between the ChromeDriver v2.36 and the Chrome Browser v69.0
Solution
Upgrade Selenium to current levels Version 3.14.0.
Upgrade ChromeDriver to current ChromeDriver v2.42 level.
Keep Chrome version between Chrome v68-70 levels. (as per ChromeDriver v2.42 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
I want to be able to set UserAgent when running Selenium mobile tests on Safari but I can't figure out how I do that. When I run the same tests on Chrome I can define the UserAgent in my desiredCapabilities like this:
var options = {
desiredCapabilities: {
browserName: 'chrome',
chromeOptions: {
args: [
'use-mobile-user-agent',
'user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OSX) ...'
]
}
}
}
Guess there must be a similar way to do it when running it on Safari. I'm using webdriverio to setup my Selenium project but don't think that should matter.
Thanks.
This is not supported by SafariDriver unfortunately. Hope we will see this in the future.