I had Selenium and Chrome working perfectly, but since last week its not working any more. This is what I get:
Caused by: org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '3.1.0', revision: '86a5d70', time: '2017-02-16 07:57:44 -0800'
System info: host: 'Scs-MacBook-Pro.local', ip: 'fe80:0:0:0:8d7:2cd3:84d5:161%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.2', java.version: '1.8.0_51'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:622)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:141)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:178)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:146)
... 14 more
Caused by: java.lang.IllegalStateException: The process has not exited yet therefore no result is available ...
at org.apache.commons.exec.DefaultExecuteResultHandler.getException(DefaultExecuteResultHandler.java:76)
at org.openqa.selenium.os.UnixProcess.checkForError(UnixProcess.java:174)
at org.openqa.selenium.os.CommandLine.checkForError(CommandLine.java:183)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:179)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:168)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
... 19 more
13:04:18.947 WARN - Exception: The process has not exited yet therefore no result is available ...
13:04:47.978 INFO - Executing: [new session: Capabilities [{acceptSslCerts=true, name=Incart Fi, browserName=chrome, javascriptEnabled=true, platform=ANY}]])
13:04:47.979 INFO - Creating a new session for Capabilities [{acceptSslCerts=true, name=Incart Fi, browserName=chrome, javascriptEnabled=true, platform=ANY}]
Starting ChromeDriver 2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9) on port 29092
Only local connections are allowed.
Now I am wondering why, since I did not change any settings. It starts the safari browser, but there the waitForElement from nightwatch does not work. So can somebody tell me by the error why I got this issue?
{
"_comment": "./selenium-server-standalone-3.0.1.jar",
"_comment2": "/Users/SCMacBook/node_modules/chromedriver/bin/chromedriver",
"src_folders" : ["tests"],
"output_folder" : "reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "",
"globals_path" : "",
"selenium" : {
"start_process" : true,
"server_path" : "./selenium-server-standalone-3.1.0.jar",
"log_path" : "",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "/Users/SCMacBook/webdriver/chromedriver",
"webdriver.gecko.driver" : "/Users/SCMacBook/webdriver/geckodriver",
"webdriver.firefox.profile" : "nightwatch"
}
},
"test_settings" : {
"default" : {
"silent": true,
"screenshots" : {
"enabled" : true,
"path" : "./pics/"
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true
}
},
"firefox" : {
"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
"safari" : {
"desiredCapabilities": {
"browserName": "safari"
}
},
"edge" : {
"desiredCapabilities": {
"platform": "WIN10",
"browserName": "MicrosoftEdge"
}
},
"ie" : {
"desiredCapabilities": {
"platform": "WIN10",
"browserName": "internet explorer",
"acceptSslCerts" : false
}
}
}
}
My solution was pretty simple and I feel espacially dumb. Somehow my /etc/hosts file was changed (MAMP ? My fault ?) and the
127.0.0.1 localhost
part was missing. So the machine couldn't use the localhost as 127.0.0.1
Hope this helps a poor someone someday :/
I also got the same error when running a nightwatch.js test and my problem was also due to a wrong entry to the /etc/hosts file:
0.0.0.0 localhost
The error went away after the above entry was removed.
Related
I need my webdriver tests use a specified chromedriver in a directory.
The problem is that when I run the tests it always uses a different chromedriver exe that was set as a default.
Command: "wdio run wdio.ci.conf.ts"
I get : "chromedriver: Starting ChromeDriver 97.0.4692.71"
ChromeDriver 97 is found in \node_modules\chromedriver\lib\chromedriver\chromedriver.exe
However in the wdio.ci.conf.ts file I set it to
services:[ ['chromedriver',{
chromeDriverCustomPath:"src\\main\\cucumber-webdriver-io\\node_modules\\webdriver-manager\\selenium\\chromedriver.exe"
}]],
At this location Im expecting it to pick an older version of chrome driver, 95.0.4638.69
I need it to run an older version as the corporate Jenkins environment has upgraded Chrome yet. In Jenkins I get the error:
WARN webdriver: Request failed with status 500 due to session not created: This version of ChromeDriver only supports Chrome version 97
[INFO] [0-0] Current browser version is 95.0.4638.69 with binary path /usr/bin/google-chrome
Thanks for your help
wdio.ci.conf.ts (removed the comments to be more brief)
const report = require('multiple-cucumber-html-reporter');
export const config: WebdriverIO.Config = {
autoCompileOpts: {
autoCompile: true,
tsNodeOpts: {
transpileOnly: true,
project: 'tsconfig.json'
}
}
},
specs: [
'./features/**/*.feature'
],
exclude: [
// 'path/to/excluded/files'
],
maxInstances: 10,
capabilities: [{
maxInstances: 5,
//
browserName: 'chrome',
'goog:chromeOptions':{
args: [ '--disable-dev-shm-usage', '--headless', '--no-sandbox', '--ignore-certificate-errors', '--test-type','--auth-server-whitelist=*bp.com', '--window-size=1440,1024', '--start-maximized']
},
acceptInsecureCerts: true,
}],
logLevel: 'info',
bail: 0,
baseUrl: 'http://localhost',
waitforTimeout: 10000,
connectionRetryTimeout: 120000,
connectionRetryCount: 3,
services:[ ['chromedriver',{
chromeDriverCustomPath:"src\\main\\cucumber-webdriver-io\\node_modules\\webdriver-manager\\selenium\\chromedriver.exe"
}]],
framework: 'cucumber',
reporters: ['cucumberjs-json'],
cucumberOpts: {
// <string[]> (file/dir) require files before executing features
require: ['./features/step-definitions/*-steps.ts'],
// <boolean> show full backtrace for errors
backtrace: false,
// <string[]> ("extension:module") require files with the given EXTENSION after requiring MODULE (repeatable)
requireModule: [],
// <boolean> invoke formatters without executing steps
dryRun: false,
// <boolean> abort the run on first failure
failFast: false,
// <boolean> hide step definition snippets for pending steps
snippets: true,
// <boolean> hide source uris
source: true,
// <boolean> fail if there are any undefined or pending steps
strict: false,
// <string> (expression) only execute the features or scenarios with tags matching the expression
tagExpression: '',
// <number> timeout for step definitions
timeout: 60000,
// <boolean> Enable this config to treat undefined definitions as warnings.
ignoreUndefinedDefinitions: false
},
onComplete: function(exitCode, config, capabilities, results) {
report.generate({
jsonDir: '.tmp/json/',
reportPath: '.tmp/report/'
});
},
}
package.json
{
"name": "cucumber-webdriver-io",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"wdio": "wdio run wdio.conf.ts",
"wdio-ci": "wdio run wdio.ci.conf.ts",
"postinstall": "rimraf -rm node_modules/wdio-html-nice-reporter/node_modules/#wdio/types"
},
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"cucumber": "^7.0.0-rc.0",
"expect-webdriverio": "^3.1.4",
"multiple-cucumber-html-reporter": "^1.18.3"
},
"devDependencies": {
"#types/chai": "^4.3.0",
"#types/node": "^17.0.12",
"#types/webdriverio": "^5.0.0",
"#wdio/cli": "^7.16.13",
"#wdio/cucumber-framework": "^7.16.13",
"#wdio/local-runner": "^7.16.13",
"#wdio/spec-reporter": "^7.16.13",
"#wdio/types": "^7.16.13",
"chai": "^4.3.6",
"chromedriver": "^97.0.2",
"cucumber-html-reporter": "^5.5.0",
"fs-extra": "^10.0.0",
"ts-node": "^10.4.0",
"typescript": "^4.5.5",
"wdio-chromedriver-service": "^7.2.6",
"wdio-cucumberjs-json-reporter": "^4.2.0",
"webdriver-manager": "^12.1.8",
"webdriverio": "^7.16.13"
}
}
Missed spelled
chromeDriverCustomPath >> chromedriverCustomPath
Since my chrome update, I cannot make any nightwatch tests work on Windows 10.
At first the system simply couldn't set values. So I updated to the latest nightwatch, then updated to latest chromedriver.exe and latest selenium jar.
Now the test simply shows data: in the url of the driven browser instead of loading the page. There is also a "disable developer mode extensions" popup and a warning that "--ignore-certificate-errors" is no longer supported.
Any ideas what I'm supposed to have done?
Chromedriver.exe version: 2.38
Selenium Standalone Server: selenium-server-standalone-3.9.1.jar
Nightwatch version: nightwatch#0.9.21
Thanks for any help. Here's my config:
{
"src_folders": ["tests"],
"output_folder": "reports",
"custom_commands_path": "",
"custom_assertions_path": "",
"page_objects_path": "pages",
"globals_path": "globals",
"selenium": {
"start_process": true,
"server_path": "./lib/selenium-server-standalone-3.9.1.jar",
"log_path": "./reports",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "./lib/chromedriver.exe"
}
},
"test_settings": {
"default": {
"launch_url": "https://modaquote.com",
"selenium_port": 4444,
"selenium_host": "localhost",
"silent": true,
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
You have to update Chromedriver to match your new version of Chrome. It should fix there issues.
I'm trying to create node with following configurations:
java -Dwebdriver.chrome.driver=/randomfolder/chromedriver -jar selenium-server-standalone-3.4.0.jar -role node -nodeConfig node-conf.json
As you see I'm passing config in a json file. It sets the configurations correctly, except the chromeOptions. I need chrome to be opened headless. This is a part of my .json file, which sets the capabilities.
"capabilities": [
{
"browserName":"chrome",
"maxInstances":3,
"version":"ServerLinux",
"platform":"LINUX",
"chromeOptions": {
"args": ["--headless", "--disable-gpu" , "--window-size=1920x1080", "--no-sandbox"]
}
}
]
I've tried different ways of writing the chromeOptions, but node keeps constantly ignoring them. Am I just blind and don't see my mistake?
Thanks in advance!
I am also facing this issue, but in my case, I want to modify the user agent, and on Linux, chromeOptions just seems to be ignored. This is working for me locally on Mac/Chrome.
//wdio.conf.js
capabilities: [{
browserName: "chrome",
chromeOptions : {
args : ['--user-agent=THIS_IS_A_TEST']
}
}],
//Jenkins job on Linux RHEA
13:42:33 [11/10/2018 13:42:33.049] [LOG] browser.desiredCapabilities = {
13:42:33 "javascriptEnabled": true,
13:42:33 "locationContextEnabled": true,
13:42:33 "handlesAlerts": true,
13:42:33 "rotatable": true,
13:42:33 "browserName": "chrome",
13:42:33 "acceptInsecureCerts": true,
13:42:33 "chromeOptions": {
13:42:33 "args": [
13:42:33 "--user-agent=THIS_IS_A_TEST",
13:42:33 "window-size=1600,1200"
13:42:33 ]
13:42:33 },
13:42:33 "loggingPrefs": {
13:42:33 "browser": "ALL",
13:42:33 "driver": "ALL"
13:42:33 }
13:42:33 }
13:42:33 [11/10/2018 13:42:33.072] [LOG] printNavigatorUserAgent() navigator.userAgent = Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36
Expected: printNavigatorUserAgent() navigator.userAgent = THIS_IS_A_TEST
printNavigatorUserAgent(){
let result = browser.execute(function() {
return navigator.userAgent;
},);
console.log(`printNavigatorUserAgent() navigator.userAgent = ${result.value}`);
}
Update: The following syntax is currently working for me on Linux/chrome.
//wdio.conf.js
capabilities: [{
browserName: "chrome",
"goog:chromeOptions" : {
"args" : ['user-agent=THIS_IS_A_TEST']
}
}],
A "try and guess" for the right JSON syntax is time consuming, and the schema might change anyway. The safest option is to pick the API for your language of choice, then assemble and generate the JSON yourself. Make sure to pick the version matching the Selenium site and stack you are targeting.
Example with Python:
from selenium.webdriver.chrome.options import Options as ChromeOptions
options = ChromeOptions()
options.add_argument('--incognito')
options.to_capabilities()
and that will look like:
{
'browserName': 'chrome',
'version': '',
'platform': 'ANY',
'goog:chromeOptions': {
'extensions': [],
'args': ['--incognito']
}
}
As a final note, if your site is bringing in a capabilities list of its own, this override and that one might get merged, so bring in your deltas only to avoid surprises.
So i saw a similar question on stack here but it did not have an accepted answer nor did it provide me with the information i needed..
I am trying to use 'chromedriver' because 'selenium-webdriver' requires a FF version <= 28.
What i've done so far.
nightwatch.js tests running fine in FF
downloaded chromedriver (npm install chromedriver -g) and also npm install chromedriver into my nightwatch project directory
went to nightwatch/bin/nightwatch.json and edited the following code
"selenium" : {
"start_process" : false,
"server_path" : "",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "/usr/local/bin/chromedriver", <= added this - is this the binary?
"webdriver.ie.driver" : "",
"webdriver.firefox.profile" : ""
}},
also tried to update the settings for selenium to have a start_process=true and server_path
"selenium" : {
"start_process" : true,
"server_path" : "../selenium-server-standalone-2.39.0.jar",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "/usr/local/bin/chromedriver",
"webdriver.ie.driver" : "",
"webdriver.firefox.profile" : ""
}
},
Not sure if im pointing to the proper chromedriver file/folder
also edited the test settings
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_host" : "127.0.0.1",
"selenium_port" : 4444,
"silent" : true,
"disable_colors": false,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities" : {
"browserName" : "chrome", <= changed this from ff to chrome
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
If i go to run the test (without a -e <browser>) e.g. nightwatch -g <group>, it launches fine in FF and runs..
If i try to specify the chrome browser (-e chrome) nightwatch -g <group> -e chrome i get the following error
ERROR There was an error while starting the test runner:
Error: Invalid testing environment specified: chrome
at Object.CliRunner.parseTestSettings (/usr/local/lib/node_modules/nightwatch/lib/runner/cli/clirunner.js:354:15)
at Object.CliRunner.init (/usr/local/lib/node_modules/nightwatch/lib/runner/cli/clirunner.js:31:8)
at module.exports.runner.runner (/usr/local/lib/node_modules/nightwatch/lib/index.js:512:19)
at /usr/local/lib/node_modules/nightwatch/bin/runner.js:9:16
at module.exports.cli.cli (/usr/local/lib/node_modules/nightwatch/lib/index.js:504:7)
at Object.<anonymous> (/usr/local/lib/node_modules/nightwatch/bin/runner.js:8:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
The questions i have are:
How do i point to the binary file (not sure which it is)
Are my settings in nightwatch.js correct? How is it running in FF if i changed the test_settings 'browserName = Chrome"?
Am i missing something here?
Thanks in advance
First you said
I am trying to use 'chromedriver' because 'selenium-webdriver'
requires a FF version <= 28.
Its because you are using selenium-server-standalone-2.39.0.jar (Old jar) Please download new one from here selenium-server-standalone-2.45.0.jar
Second Download chrome driver from here Chromedriver basis on your environment
Third update your nightwatch.json with below code
{
"src_folders": [
"tests"
],
"selenium": {
"start_process": false,
"server_path": "bin/selenium-server-standalone-2.45.0.jar",
"log_path": "",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "bin/chromedriver",
"webdriver.ie.driver": ""
}
},
"test_settings": {
"default": {
"launch_url": "http://127.0.0.1/",
"selenium_port": 4444,
"selenium_host": "localhost",
"silent": true,
"screenshots": {
"enabled": false,
"path": ""
},
"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
Fourth run your group with nightwatch -g -e chrome
Hope It will solve your problem.
Make sure to create a new nightwatch.json file in the root of your project.
The mistake i made was trying to use the nightwatch.json file that came with the package downlaoded from http://nightwatchjs.org/ that resided in nightwatch-0.6.11/bin/nightwatch.json
"selenium": {
"start_process":true,
"server_path": "bin/selenium.jar",
"log_path": "",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "",
"webdriver.ie.driver": ""
}
},
above code helps me to run selenium server by nightwatch
Env: chromedriver 2.9, google-chrome-stable 34, python 2.6, CentOS6.4 final x86_64
I install google-chrome-stable(not chromium) follow install-chrome.sh. It may extract packages from fedoraproject and install those package to /opt/google/chrome/lib. I install chromedriver2.9 follow link. I can run google-chrome and chromedriver manually without error. I install selenium by pip install selenium(selenium 2.41 ). Selenium is installed to /usr/lib/python2.6/site-packages/. Google-chrome installed at this manner seems not allowed to open as root.
When I run code under python console with non root user as follow:
>>> from selenium import webdriver
>>> driver = webdriver.Chrome()
It return error message as follow instead of openning chrome.
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "/usr/lib/python2.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 65, in __init__
keep_alive=True)
File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/webdriver.py", line 72, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/webdriver.py", line 115, in start_session
'desiredCapabilities': desired_capabilities,
File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/webdriver.py", line 166, in execute
self.error_handler.check_response(response)
File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 164, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: u'unknown error: Chrome failed to start: crashed\n (Driver info: chromedriver=2.9.248304,platform=Linux 2.6.32-358.el6.x86_64 x86_64)'
I get log follow linkUnknown error: Chrome failed to start: exited abnormally. There is no solution on that link. What should I do? Thanks.
[0.987][INFO]: COMMAND InitSession {
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"args": [ ],
"extensions": [ ]
},
"javascriptEnabled": true,
"platform": "ANY",
"version": ""
},
"sessionId": null
}
[0.987][INFO]: Populating Preferences file: {
"alternate_error_pages": {
"enabled": false
},
"autofill": {
"enabled": false
},
"browser": {
"check_default_browser": false
},
"distribution": {
"import_bookmarks": false,
"import_history": false,
"import_search_engine": false,
"make_chrome_default_for_user": false,
"show_welcome_page": false,
"skip_first_run_ui": true
},
"dns_prefetching": {
"enabled": false
},
"profile": {
"content_settings": {
"pattern_pairs": {
"https://*,*": {
"media-stream": {
"audio": "Default",
"video": "Default"
}
}
}
},
"default_content_settings": {
"geolocation": 1,
"mouselock": 1,
"notifications": 1,
"popups": 1,
"ppapi-broker": 1
},
"password_manager_enabled": false
},
"safebrowsing": {
"enabled": false
},
"search": {
"suggest_enabled": false
},
"translate": {
"enabled": false
}
}
[0.988][INFO]: Populating Local State file: {
"background_mode": {
"enabled": false
},
"ssl": {
"rev_checking": {
"enabled": false
}
}
}
[0.988][INFO]: Launching chrome: /opt/google/chrome/google-chrome --disable-background-networking --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-hang-monitor --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --full-memory-crash-report --ignore-certificate-errors --load-extension=/tmp/.com.google.Chrome.NnyvZ9/internal --logging-level=1 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12775 --safebrowsing-disable-auto-update --safebrowsing-disable-download-protection --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.AtCYvH data:,
[0.989][DEBUG]: DevTools request: http://127.0.0.1:12775/json/version
[0.991][WARNING]: PAC support disabled because there is no system implementation
[1.034][DEBUG]: DevTools request failed
[1.084][DEBUG]: DevTools request: http://127.0.0.1:12775/json/version
[1.085][DEBUG]: DevTools request failed
[1.135][DEBUG]: DevTools request: http://127.0.0.1:12775/json/version
[1.136][DEBUG]: DevTools request failed
.....
.....
[61.022][DEBUG]: DevTools request: http://127.0.0.1:12775/json/version
[61.024][DEBUG]: DevTools request failed
[61.024][INFO]: RESPONSE InitSession unknown error: Chrome failed to start: crashed
[61.025][DEBUG]: Log type 'driver' lost 0 entries on destruction
[61.025][DEBUG]: Log type 'browser' lost 0 entries on destruction
I am confused about those DevTools things, either.
Are you using headless? If so, you will have to specify the headless display through pyvirtualdisplay.
I had the same error (log) when I was running selenium headless without telling selenium to use visual display. After installing pyvirtualdisplay, the following code works for me:
from selenium import webdriver
from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 600))
display.start()
driver = webdriver.Chrome()
driver.get("http://www.google.com")
print driver.page_source.encode('utf-8')
driver.quit()
display.stop()