Error
I see:
/opt/narjetas/node_modules/selenium-webdriver/lib/error.js:524
let err = new ctor(data.message)
^
WebDriverError: unknown error: Chrome failed to start: crashed.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
at Object.throwDecodedError (/opt/narjetas/node_modules/selenium-webdriver/lib/error.js:524:15)
at parseHttpResponse (/opt/narjetas/node_modules/selenium-webdriver/lib/http.js:587:13)
at Executor.execute (/opt/narjetas/node_modules/selenium-webdriver/lib/http.js:515:28)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
remoteStacktrace: '#0 0x564c9d0c4463 <unknown>\n' +
'#1 0x564c9ce888d8 <unknown>\n' +
'#2 0x564c9ceb0b6a <unknown>\n' +
'#3 0x564c9ceabc05 <unknown>\n' +
'#4 0x564c9ceef802 <unknown>\n' +
'#5 0x564c9ceef2af <unknown>\n' +
'#6 0x564c9cee7443 <unknown>\n' +
'#7 0x564c9ceb83c5 <unknown>\n' +
'#8 0x564c9ceb9531 <unknown>\n' +
'#9 0x564c9d116dce <unknown>\n' +
'#10 0x564c9d11a192 <unknown>\n' +
'#11 0x564c9d0fb93e <unknown>\n' +
'#12 0x564c9d11b103 <unknown>\n' +
'#13 0x564c9d0eed85 <unknown>\n' +
'#14 0x564c9d13c0a8 <unknown>\n' +
'#15 0x564c9d13c239 <unknown>\n' +
'#16 0x564c9d157492 <unknown>\n' +
'#17 0x7f6d909171cf start_thread\n'
}
System is RHEL 8, running in headless mode. This runs without issue on Windows. I have triple checked the chromedriver version and my browser version and they match. The error generates on this line:
let driver = new Builder()
.forBrowser('chrome')
.setChromeOptions(new chrome.Options().headless().windowSize(screen))
.build();
System Info
It is running on top of nodejs.
Chrome version:
[grant#lab backend]$ google-chrome --version
Google Chrome 107.0.5304.87
I am using this version of chromedriver (the minor versions don't match but they shouldn't need to and this did not present any issues on Windows - there is no Chromedriver for the current minor version afaik)
Permissions
Permissions for chromedriver are 755 and it is running as user (grant)
This isn't the right answer, but if someone else comes here stuck, I just swapped Chrome for Firefox and it worked like a champ out of the box.
console.log("BUILD 1");
let driver = new Builder()
.forBrowser('firefox')
.setFirefoxOptions(new firefox.Options().headless().windowSize(screen))
.build();
That was the only change I had to make and it came up immediately.
I had the same issue, but resolved it by installing Java openjdk
yum install java-1.8.0-openjdk-1.8.0.322.b06 -y
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.
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.)
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 have protractor installed in project folder + web-manager (installed the same way).
The web-manager is started:
$npm-run webdriver-manager status
webdriver-manager: using global installed version 12.0.6
- selenium standalone version available: 3.8.1 [last]
- chromedriver version available: 2.35 [last]
- geckodriver version available: v0.19.1 [last]
- IEDriverServer is not present
However, when I run protractor
$ npm-run protractor conf.js
[15:22:12] I/launcher - Running 1 instances of WebDriver
[15:22:12] E/local - Error code: 135
[15:22:12] E/local - Error message: No update-config.json found. Run 'webdriver-manager update' to download binaries.
[15:22:12] E/local - Error: No update-config.json found. Run 'webdriver-manager update' to download binaries.
Here is my conf.js for protractor
exports.config = {
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome',
},
// Spec patterns are relative to the current working directly when
// protractor is called.
specs: ['tests/common/*.js'],
};
How do I fix the config/run protrator?
you need to run npm-run webdriver-manager update to install webdriver binary and selenium-standalon-server.jar if you never execute it, otherwise the command will update existed stuff.
After that, find update-config.json in node_modules\protractor\node_modules\webdriver-manager\selenium.
Its content should be like this:
{
"chrome": {
"last": "xxx\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\chromedriver_2.35.exe",
"all": ["xxx\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\chromedriver_2.35.exe"]
},
"standalone": {
"last": "xxx\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\selenium-server-standalone-3.9.0.jar",
"all": ["xxx\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\selenium-server-standalone-3.9.0.jar"]
},
"gecko": {
"last": "xxx\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\geckodriver-v0.19.1.exe",
"all": ["xxx\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\geckodriver-v0.19.1.exe"]
}
}
Then execute node_modules\.bin\webdriver-manager start to see will success or fail.
FYI, you need JDK 8 installed to start webdriver-manager.
Finally, found a solution using gulp.
The config below allows to run webmanager-update, webmanager-start and proptractor on by one.
gulp.js
var gulp = require('gulp'),
shell = require('gulp-shell'),
connect = require('gulp-connect'); // Webserver
protractor = require('gulp-protractor').protractor,
webdriver_standalone = require('gulp-protractor').webdriver_standalone,
webdriver_update = require('gulp-protractor').webdriver_update;
gulp.task('webdriver_update', webdriver_update);
gulp.task('webdriver_standalone', webdriver_standalone);
gulp.task('e2e', ['webdriver_update'], function() {
gulp.src(["tests/protractor/*.js"])
.pipe(protractor({
configFile: "protractor.conf.js",
args: [
//'--baseUrl', 'http://127.0.0.1:8000',
// '--suite', 'login',
// '--params.environment', 'test'
]
}))
.on('error', function(e) { throw e })
});
protractor.conf.js
exports.config = {
seleniumServerJar: './node_modules/webdriver-manager/selenium/selenium-server-standalone-3.9.0.jar',
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome',
},
};
(using URL for selenium server is impotant)
Launch command:
gulp e2e