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.
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 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"
So I have setup some Selenium tests to run on OpenShift on headless Chrome + Firefox. They run fine on my Windows machine on a browser with GUI, and Chrome headless also works fine.
For Firefox I get the error message "connection refused" and geckodriver doesnt seem to be able to connect to Firefox.
I found a dozen of posts about this matter, but no solution so far.
Anyone got any advice on this?
thanks a lot!
Desired Capabilities
public static DesiredCapabilities getFirefoxCapabilities () {
DesiredCapabilities caps = DesiredCapabilities.firefox();
caps.setPlatform(org.openqa.selenium.Platform.ANY);
FirefoxOptions options = new FirefoxOptions();
options.setBinary("/usr/lib64/firefox/firefox-bin");
options.setHeadless(true);
options.addArguments("--disable-gpu");
options.addArguments("--allow-insecure-localhost");
options.addArguments("--remote-debugging-port=9222");
options.setAcceptInsecureCerts(true);
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("sanity-test.running", true);
options.setProfile(profile);
caps.merge(options);
return caps;
}
Setup of Webdriver implementation
System.setProperty("webdriver.gecko.driver", openshift_browserDriverPath_Firefox);
try {
driver.set(new FirefoxDriver(headlessDriverCapabilityFactory.getCapabilities(getBrowserName())));
}
catch(Exception e) {
System.out.println("setup headless ff: " + e.getMessage() + "failed at " + e.getStackTrace());
}
Excerpt from Jenkins Log
1565697695283 mozrunner::runner INFO Running command:
"/usr/lib64/firefox/firefox-bin" "-marionette" "-headless" "--disable-
gpu" "--allow-insecure-localhost" "--remote-debugging-port=9222" "-
foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile.LMzPtqcIh6wS"
*** You are running in headless mode.
1565697700885 addons.xpi WARN Can't get modified time of
/usr/lib64/firefox/browser/features/aushelper#mozilla.org.xpi
1565697701079 addons.xpi-utils WARN addMetadata: Add-on
aushelper#mozilla.org is invalid: [Exception... "Component returned
failure code: 0x80520006 (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)
[nsIFile.isFile]" nsresult: "0x80520006
(NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)" location: "JS frame ::
resource://gre/modules/addons/XPIInstall.jsm :: loadManifestFromFile ::
line 925" data: no] Stack trace:
loadManifestFromFile()#resource://gre/modules/addons/XPIInstall.jsm:925 syncLoadManifestFromFile()#resource://gre/modules/addons/XPIProvider.jsm:940
addMetadata()#resource://gre/modules/addons/XPIProvider.jsm ->
resource://gre/modules/addons/XPIProviderUtils.js:1173
processFileChanges()#resource://gre/modules/addons/XPIProvider.jsm ->
resource://gre/modules/addons/XPIProviderUtils.js:1529
checkForChanges()#resource://gre/modules/addons/XPIProvider.jsm:3304
startup()#resource://gre/modules/addons/XPIProvider.jsm:2196
callProvider()#resource://gre/modules/AddonManager.jsm:253
_startProvider()#resource://gre/modules/AddonManager.jsm:728
startup()#resource://gre/modules/AddonManager.jsm:892
startup()#resource://gre/modules/AddonManager.jsm:298 observe()#jar:file:///usr/lib64/firefox/omni.ja!/components/addonManager.js
:63
1565697701094 addons.xpi-utils WARN Could not uninstall invalid
item from locked install location
Aug 13, 2019 12:01:44 PM org.openqa.selenium.remote.ProtocolHandshake
createSession
INFO: Detected dialect: W3C
#Test - internal test: Chrome browser headless
Aug 13, 2019 12:01:46 PM cucumber.runtime.java.ObjectFactoryLoader
loadSingleObjectFactory
WARNING: Use deprecated reflections to load ObjectFactory.
setup headless ff: connection refused
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-
14T08:17:03'
System info: host: 'ifx-java-slave-browsers.latest-6llvz', ip:
'10.125.24.3', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-
862.el7.x86_64', java.version: '1.8.0_222'
Driver info: driver.version: FirefoxDriver
#Daniel Davison's article on OpenShift Templates for Selenium can provide you with all the steps required to leverage openshift with Selenium within Docker containers in creating a scale-able framework for Selenium.
Here are the required links:
Configuration for Selenium Hub
Configuration for Selenium Node - Chrome
Configuration for Selenium Node - Firefox
I'm setting up CI for our project that is in Angular. We are using Google Cloud Platform's Cloud Builder for CI. Everything is going smoothly, we can setup the environment, install packages via npm, build the project using angular-cli and deploy. But the problem is that our test cases (e2e) in Protractor keeps getting an error. What are we missing here?
This is for the Continuous Integration using Google Cloud Builders, we are running the protractor in headless mode, and using the puppeteer's chromium as the chrome's binary path
This is my protractor.conf.js
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
const puppeteer = require('puppeteer');
process.env.CHROME_BIN = puppeteer.executablePath()
exports.config = {
allScriptsTimeout: 1000000,
specs: [
'./e2e/*.e2e-spec.ts',
'../e2e/*.e2e-spec.ts'
],
capabilities: {
// browserName: 'chrome',
browserName: 'chrome',
chromeOptions: {
binary: process.env.CHROME_BIN,
args: ['--headless', '--disable-gpu', '--no-sandbox', '--disable-extensions', '--disable-dev-shm-usage', '--disable-setuid-sandbox']
}
},
// seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
// ignoreUncaughtExceptions: true,
directConnect: true,
},
};
This is the error we are getting in cloud builders
[11:24:12] E/launcher - unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /workspace/node_modules/puppeteer/.local-chromium/linux-662092/chrome-linux/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.15.0-1033-gcp x86_64)
[11:24:12] E/launcher - WebDriverError: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /workspace/node_modules/puppeteer/.local-chromium/linux-662092/chrome-linux/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
After upgrading to chromedriver 74 noticed odd extensions behaviour on Windows.
Is it possible to switch ALL extensions off?
Start chromedriver
chromedriver --log-level=ALL
Create session with extensions DISABLED
curl -d '{"desiredCapabilities":{"browserName":"chrome","goog:chromeOptions":{"args":["--disable-extensions"]}}}' http://localhost:9515/session
Some dev tool extension is loaded
[1558606783.990][INFO]: Launching chrome: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-extensions --disable-extensions-except="C:\Users\user\AppData\Local\Temp\scoped_dir19964_411\internal" --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging --force-fieldtrials=SiteIsolationExtensions/Control --ignore-certificate-errors --log-level=0 --no-first-run --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\user\AppData\Local\Temp\scoped_dir19964_22650" data:,
Note
--disable-extensions-except="C:\Users\user\AppData\Local\Temp\scoped_dir19964_411\internal"
Is there a way to get rid of it? Did not find any clues in chromedriver docs, those are extremely sketchy.
TL;DR
Set chromeOptions.useAutomationExtension to false, it will prevent injecting of Chrome Automation Extension
{
"desiredCapabilities": {
"browserName": "chrome",
"goog:chromeOptions": {
"useAutomationExtension": false,
"args": [
"--disable-extensions"
]
}
}
}
Long version
Automation Extension flag is not mentioned in chromedriver docs http://chromedriver.chromium.org/capabilities, but can be traced in source code for current version (75.0.)
parser_map["useAutomationExtension"] =
base::Bind(&ParseBoolean, &capabilities->use_automation_extension);
status = internal::ProcessExtensions(
capabilities.extensions, extension_dir->GetPath(),
capabilities.use_automation_extension, &switches, extension_bg_pages);
if (include_automation_extension) {
...
if (switches->HasSwitch("disable-extensions")) {
UpdateExtensionSwitch(switches, "disable-extensions-except",
automation_extension.value());
As mentioned in 54594305 Java code using selenium driver would be
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("useAutomationExtension", false);