I'm getting an error when trying to set up a phantomjs node on Selenium Grid (https://wiki.jenkins-ci.org/display/JENKINS/Selenium+Plugin)
I've set up the following custom json configuration:
{
"capabilities": [
{
"browserName": "phantomjs",
"phantomjs.binary.path": "/usr/bin/phantomjs",
"platform": "LINUX",
"maxInstances": 5
}
],
"configuration": {
"nodeTimeout":120,
"port":5555,
"hubPort":4444,
"hubHost":"localhost",
"nodePolling":2000,
"registerCycle":10000,
"register":true,
"cleanUpCycle":2000,
"timeout":30000,
"maxSession":1
}
}
But I get an error when I run webdriver against it:
WebDriverException: Message: The path to the driver executable must be set by the phantomjs.binary.path capability/system property/PATH variable; for more information, see https://github.com/ariya/phantomjs/wiki. The latest version can be downloaded from http://phantomjs.org/download.html
Stacktrace:
at com.google.common.base.Preconditions.checkState (Preconditions.java:199)
at org.openqa.selenium.phantomjs.PhantomJSDriverService.findPhantomJS (PhantomJSDriverService.java:236)
at org.openqa.selenium.phantomjs.PhantomJSDriverService.createDefaultService (PhantomJSDriverService.java:181)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init> (PhantomJSDriver.java:104)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (NativeConstructorAccessorImpl.java:-2)
at sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance (Constructor.java:526)
at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor (DefaultDriverProvider.java:103)
at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance (DefaultDriverProvider.java:97)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance (DefaultDriverFactory.java:60)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call (DefaultSession.java:222)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call (DefaultSession.java:1)
at java.util.concurrent.FutureTask.run (FutureTask.java:262)
at org.openqa.selenium.remote.server.DefaultSession$1.run (DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:615)
at java.lang.Thread.run (Thread.java:745)
-------------------- >> begin captured logging << --------------------
selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session {"desiredCapabilities": {"browserName": "phantomjs"}}
selenium.webdriver.remote.remote_connection: DEBUG: Finished Request
If I stop the node started by the plugin (and keep the plugin hub running), and manually run my own node as follows, it works fine:
java -jar selenium-server-standalone-2.53.0.jar -role webdriver
-browser browserName=phantomjs,platform=LINUX
-hub http://localhost:4444/grid/register
[edit] phantomjs is executable from the shell and lives at /usr/bin/phantomjs:
$ whereis phantomjs
phantomjs: /usr/bin/phantomjs
I can't find a canonical description online of a phantomjs setup and this isn't one of the default browser options provided by the plugin.
The problem with the above was the OS permissions on /usr/bin/phantomjs; I needed to do chmod a+x on it.
Cheekily adding this additional problem
This works (manually started by me):
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.111.x86_64/jre/bin/java -jar /var/lib/jenkins/selenium-server-standalone-2.53.0.jar -role webdriver -browser browserName=phantomjs,platform=LINUX -hub http://localhost:4444/grid/register
This doesn't (the process started by the selenium plugin):
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.111.x86_64/jre/bin/java -cp /var/cache/jenkins/war/WEB-INF/lib/remoting-2.56.jar hudson.remoting.Launcher -cp /var/lib/jenkins/selenium-server-standalone-2.53.0.jar:/var/lib/jenkins/htmlunit-driver-standalone-2.20.jar -connectTo localhost:36322
Error I'm getting when running the test:
PHPUnit_Extensions_Selenium2TestCase_WebDriverException: The process has not exited yet therefore no result is available
Adding the answer just in case someone misses the comment.
Please check if phantomjs has 'x' (execute) access for all users. If it doesnt, then use the command to change the access.
chmod +x /usr/bin/phantomjs
The new error "The process has not exited yet therefore no result is available" mostly comes with selenium/driver version mismatch. You could try downgrading the version of selenium.
Btw, what version of phantomjs are you using.
Try adding -Dphantomjs.binary.path=/usr/bin/phantomjs to your Java flags for Jenkins (typically look to /etc/default/jenkins or /etc/sysconfig/jenkins).
juste add path in command line like this:
'/usr/bin/java' -Dphantomjs.binary.path='/home/john/.local/share/binman_phantomjs/linux64/2.1.1/phantomjs-2.1.1-linux-x86_64/bin/phantomjs' -jar '/home/john/.local/share/binman_seleniumserver/generic/3.0.1/selenium-server-standalone-3.0.1.jar'
Related
Server: Raspberry Pi 3
OS: Dietpi - version 159
Geckodriver version: 0.22 for arm
Firefox version: 52.9.0
Python version: 3.5
Selenium version: 3.14.1
Gecko is executable, and is located in /usr/local/bin/
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.firefox.options import Options
import time
options = Options()
options.set_headless(headless=True)
driver = webdriver.Firefox(firefox_options=options)
print('Need your login credential')
username = input('What is your username?:\n')
password = input('What is your password?:\n')
...
...
Output:
root#RPi3:~# python3.5 ITE-bot.py
Traceback (most recent call last):
File "ITE-bot.py", line 12, in <module>
driver = webdriver.Firefox(firefox_options=options)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
keep_alive=True)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process
Any idea what is wrong? I've tried google without luck.
If you are running Firefox on a system with no display, make sure you use headless mode.
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.headless = True
driver = webdriver.Firefox(options=options)
Also, make sure you have compatible versions of Firefox, Selenium, and Geckodriver:
https://firefox-source-docs.mozilla.org/testing/geckodriver/Support.html
Thumb rule
A common cause for Browsers to crash during startup is running WebDriver initiated Browsers as root user (administrator) on Linux. While it is possible to work around this issue by passing --no-sandbox flag when creating your WebDriver session, such a configuration is unsupported and highly discouraged. You need to configure your environment to run Browser as a regular user instead.
This error message...
selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process
...implies that the GeckoDriver was unable to initiate/spawn a new WebBrowsing Session i.e. Firefox Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
Your GeckoDriver version is 0.22.0.
Release Notes of GeckoDriver v0.21.0 (2018-06-15) clearly mentions the following:
Firefox 57 (and greater)
Selenium 3.11 (and greater)
Your Firefox version is 52.9.0.
So there is a clear mismatch between GeckoDriver v0.22.0 and the Firefox Browser v57
Solution
Upgrade GeckoDriver to GeckoDriver v0.22.0 level.
GeckoDriver is present in the specified location.
GeckoDriver is having executable permission for non-root users.
Upgrade Firefox version to Firefox v62.0.2 levels.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
Execute your Selenium Test as a non-root user.
GeckoDriver, Selenium and Firefox Browser compatibility chart
I was on headless mode, using correct versions of everything, and the only way to get out of this error message was not to execute the selenium test as root
Yes checked Start Xvfb before the build can fix the problem, but if you have a job like a pipeline or multibranch pipeline this option is not visible. In the node of your Selenium grid that you go to execute the test you need:
1- Install Xvfb: apt install xvfb
2- Execute Xvfb: /usr/bin/Xvfb :99 -ac -screen 0 1024x768x8 & export DISPLAY=":99"
3- Rerun your node, for example: java -jar selenium.jar -role node -hub http://#.#.#.#:4444/grid/register -capabilities browserName=firefox,plataform=linux -host #.#.#.# -port 1991
This solution worked for me
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.headless = True
driver = webdriver.Firefox(options=options)
As there can be many different underlying causes for this error it is best to find the root cause setting selenium to use debug level logging. In my case, for Ruby with capybara I needed to set: Selenium::WebDriver.logger.level = :debug. And voilà, running the same spec I could see in the logs that a dependency was missing, in my case:
libdbus-glib-1.so.2: cannot open shared object file: No such file or directory
Couldn't load XPCOM.
After installing it all worked fine.
I used:
VS Code
Linunx/Ubuntu:18.10
Nightwatch.js
My problem was that I tried to run Nightwatch (which automatically starts GeckoDriver) from the VS Code terminal.
I had the same problem, and realized that the real problem was some firefox dependencies not being installed inside the docker container I was testing in.
Try to initiate firefox and check if it returns an error.
As Nico and jay have stated you need to check the logs to see the details of the error. As you might use different systems, you can specify the path where the log is stored (i.e. "/tmp/geckodriver.log").
from selenium import webdriver
firefox_options = webdriver.firefox.webdriver.Options()
driver = webdriver.Firefox(log_path="/tmp/geckodriver.log",
options=firefox_options)
In my particular case, what the log said was:
Error: no DISPLAY environment variable specified
That was resolved adding in the options the headless mode before starting the driver. With the line:
firefox_options.set_headless()
I was able to fix this by running my tests with Xvfb. I was running them on a remote server.
I was using Jenkins so I checked the box that looked like this:
Credit to https://www.obeythetestinggoat.com/book/chapter_CI.html
in my case, I was running test cases as root
geckodriver.log
1576076416677 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofilenCbl2e"
Running Firefox as root in a regular user's session is not supported. ($HOME is /home/seluser which is owned by seluser.)
1576077143004 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile7wpSQ7"
1576077143689 addons.webextension.screenshots#mozilla.org WARN Loading extension 'screenshots#mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons
1576077143689 addons.webextension.screenshots#mozilla.org WARN Loading extension 'screenshots#mozilla.org': Reading manifest: Invalid extension permission: telemetry
1576077143689 addons.webextension.screenshots#mozilla.org WARN Loading extension 'screenshots#mozilla.org': Reading manifest: Invalid extension permission: resource://pdf.js/
1576077143689 addons.webextension.screenshots#mozilla.org WARN Loading extension 'screenshots#mozilla.org': Reading manifest: Invalid extension permission: about:reader*
1576077145372 Marionette INFO Listening on port 35571
1576077145423 Marionette WARN TLS certificate errors will be ignored for this session
1576077200207 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofilenhoHlr"
Running Firefox as root in a regular user's session is not supported. ($HOME is /home/seluser which is owned by seluser.)
i could get around by
cd /home
chown -R root seluser
i woundnt say its correct but it got my job done
I'm using Selenium for testing from Java code, it's started automatically with maven, when I run mvn verify it uses gecko-driver to start new firefox instance for selenium:
final FirefoxOptions opts = new FirefoxOptions();
if (HEADLESS_MODE) {
opts.addArguments(ARG_HEADLESS);
}
return new FirefoxDriver(opts);
It's working fine on my machine (and on machines of other developers) in both modes "headless" and normal. Now I'm trying to run Selenium tests with CI builds in Alpine Linux Docker container. When I tried to run it as-is, I've got an error:
mozrunner::runner INFO Running command: "/usr/bin/firefox"
"-marionette" "--headless" "-foreground" "-no-remote"
"-profile" "/tmp/rust_mozprofile.pW1sbkcv98QN"
Error: GDK_BACKEND does not match available displays.
Then I installed all suggested tools (dbus and xvfb) from this post and started it before running tests:
apk add xvfb dbus
dbus-uuidgen > /etc/machine-id
export DISPLAY=:99
Xvfb $DISPLAY -ac &
mvn verify
but now Selenium tests are hadning for about 10 seconds and failing with error
1565433736375 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "--headless" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile.1ZMsJ0Hy95V0"
1565433738424 Marionette INFO Listening on port 2828
!!! [Child][MessageChannel] Error: (msgtype=0x3E0003,name=PCompositable::Msg_Destroy) Channel error: cannot send/recv
[Child 2191] ###!!! ABORT: Aborting on channel error.: file /home/buildozer/aports/community/firefox-esr/src/firefox-52.8.1esr/ipc/glue/MessageChannel.cpp, line 2152
[Child 2191] ###!!! ABORT: Aborting on channel error.: file /home/buildozer/aports/community/firefox-esr/src/firefox-52.8.1esr/ipc/glue/MessageChannel.cpp, line 2152
!!! [Child][MessageChannel] Error: (msgtype=0x3E0003,name=PCompositable::Msg_Destroy) Channel error: cannot send/recv
It seems I'm doing something wrong here, what is the correct way to run headless Selenium tests in Alpine Linux Docker container? I'd prefer to configure existing Docker image instead of using Selenium images, because the migration will be expensive.
Update:
Selenium version is 3.141.59
Gecko-driver version is v0.24.0-linux64
Firefox-ESR version is: 52.8.1-r0
Update2:
xvfb, dbus and exported DISPLAY are not actually needed to run Firefox in headless mode - just run firefox --headless and it's all.
As per Mozilla --headless flag is not supported in Firefox 52-esr.Headless flag was introduced in version 55 (for Linux) and 56 (Mac/Windows) . Please try on latest Firefox ESR release.
I have problem with Selenium Grid. Then I try to connect to node, i've got an error on node side.+
U run hub by this way:
java -jar .\selenium-server-standalone-3.141.59.jar -role hub
I run node by this way:
java -jar .\selenium-server-standalone-3.141.59.jar -role node -nodeConfig .\NodeConfig.json
NodeConfig.json:
{
"capabilities":
[
{
"browserName": "chrome",
"platform": "WINDOWS",
"maxInstances": 5,
"chrome_binary":"chromedriver.exe",
"seleniumProtocol": "WebDriver",
"nodeName": "Local Chrome Node"
}
],
"maxSession": 5,
"port": 5555,
"register": true,
"registerCycle": 5,
"hub": "http://localhost:4444",
"webdriver.chrome.driver":"<path to chromedriver.exe>"
"nodeStatusCheckTimeout": 5,
"nodePolling": 5,
"role": "node",
"unregisterIfStillDownAfter": 60,
"downPollingLimit": 2,
"debug": false,
"servlets" : [],
"withoutServlets": [],
"custom": {}
}
Simplyfied Java code:
DriverService service = null;
ChromeOptions opts = new ChromeOptions();
opts.addArguments("-incognito");
opts.addArguments("--no-sandbox");
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), opts);
On Java side:
A long stacktrace (I think it's not necessary for this problem)
On Node side:
java -jar .\selenium-server-standalone-3.141.59.jar -role node
-nodeConfig .\NodeConfig.json 15:39:56.377 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision:
e82be7d358 15:39:56.513 INFO
[GridLauncherV3.lambda$buildLaunchers$7] - Launching a Selenium Grid
node on port 5555 2019-06-18 15:39:56.921:INFO::main: Logging
initialized #807ms to org.seleniumhq.jetty9.util.log.StdErrLog
15:39:57.200 INFO [WebDriverServlet.] - Initialising
WebDriverServlet 15:39:57.292 INFO [SeleniumServer.boot] - Selenium
Server is up and running on port 5555 15:39:57.293 INFO
[GridLauncherV3.lambda$buildLaunchers$7] - Selenium Grid node is up
and ready to register to the hub 15:39:57.456 INFO
[SelfRegisteringRemote$1.run] - Starting auto registration thread.
Will try to register every 5 ms. 15:39:57.955 INFO
[SelfRegisteringRemote.registerToHub] - Registering the node to the
hub: http://localhost:4444/grid/register 15:39:58.106 INFO
[SelfRegisteringRemote.registerToHub] - The node is registered to the
hub and ready to use 15:40:06.931 INFO [ActiveSessionFactory.apply]
- Capabilities are: { "browserName": "chrome", "goog:chromeOptions": {
"args": [
"-incognito",
"--no-sandbox"
],
"extensions": [
],
"binary": "chromedriver.exe" } } 15:40:06.933 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory
org.openqa.selenium.grid.session.remote.ServicedSession$Factory
(provider: org.openqa.selenium.chrome.ChromeDriverService) Starting
ChromeDriver 75.0.3770.90
(a6dcaf7e3ec6f70a194cc25e8149475c6590e025-refs/branch-heads/3770#{#1003})
on port 21040 Only local connections are allowed. Please protect
ports used by ChromeDriver and related test frameworks to prevent
access by malicious code. Starting ChromeDriver 75.0.3770.90
(a6dcaf7e3ec6f70a194cc25e8149475c6590e025-refs/branch-heads/3770#{#1003})
on port 9515 Only local connections are allowed. Please protect
ports used by ChromeDriver and related test frameworks to prevent
access by malicious code. Invalid --log-level value. Unable to
initialize logging. Exiting...
On Hub side:
java -jar .\selenium-server-standalone-3.141.59.jar -role hub
15:39:50.884 INFO [GridLauncherV3.parse] - Selenium server version:
3.141.59, revision: e82be7d358 15:39:51.000 INFO [GridLauncherV3.lambda$buildLaunchers$5] - Launching Selenium Grid hub
on port 4444 2019-06-18 15:39:51.425:INFO::main: Logging initialized
#805ms to org.seleniumhq.jetty9.util.log.StdErrLog 15:39:51.831 INFO
[Hub.start] - Selenium Grid hub is up and running 15:39:51.832 INFO
[Hub.start] - Nodes should register to http://%My IP%:4444/grid/register/ 15:39:51.832 INFO [Hub.start] - Clients
should connect to http://%My IP%:4444/wd/hub 15:39:58.105 INFO
[DefaultGridRegistry.add] - Registered a node http://:5555
15:40:06.623 INFO [RequestHandler.process] - Got a request to create a
new session: Capabilities {browserName: chrome, goog:chromeOptions:
{args: [-incognito, --no-sandbox], extensions: []}} 15:40:06.632
INFO [TestSlot.getNewSession] - Trying to create a new session on test
slot {chrome_binary=chromedriver.exe, nodeName=Local Chrome Node,
server:CONFIG_UUID=186192e2-e951-4cef-b527-291aa9c0e2f5,
seleniumProtocol=WebDriver, webdriver.chrome.driver=/chromedriver.exe, browserName=chrome, maxInstances=1,
platformName=WINDOWS, version=75, platform=WINDOWS}
So, how to sole this problem and configure logs on node side (I'd like to made it via .json file)
Analyzing the NodeConfig.json and both Selenium Grid Hub and Selenium Grid Hub logs, there seems to be an issue with the --no-sandbox argument.
Sandbox
The sandbox library which allows the creation of sandboxed processes that can execute within a very restrictive environment cannot write to disk. Chromium renderers are sandboxed processes.
Solution
Some more information about Selenium client, ChromeDriver / Chrome version would have helped us to debug the issue in a better way. However as you are using Chrome in regular mode (non headless), you may drop the argument --no-sandbox.
tl; dr
Unable to Create Driver Instance for chrome in ubuntu
I just came across this error and fixed it. The "Invalid --log-level value" error is caused by using ChromeDriver as Chrome. Selenium runs ChromeDriver, then ChromeDriver runs Chrome. Chrome recognise "--log-level=0", but not ChromeDriver.
What's happening here is that you try to use ChromeDriver to run ChromeDriver. The reason can be specifying ChromeDriver's path as Chrome. E.g. symbolic link chromedriver as chrome, or ChromeOptions.setBinary(".../chromedriver")
I can access url and create sessions:
http://localhost:4444/wd/hub/static/resource/hub.html
but when i execute ./codecept run i get an error, but i have Selenium Server running:
[ConnectionException] Can't connect to Webdriver at http://127.0.0.1:4444/wd/hub. Please make sure that Selenium Server or PhantomJS is running.
To execute Selenium Server, i used this command:
java -Dwebdriver.gecko.driver=./geckodriver -jar "selenium-server-standalone-3.12.0.jar"
I tried too with IE and Chrome (i have the same problem too):
java -Dwebdriver.chrome.driver=./chromedriver -jar "selenium-server-standalone-3.12.0.jar"
java -Dwebdriver.ie.driver=./IEDriverServer -jar "selenium-server-standalone-3.12.0.jar"
acceptance.suite.yml
class_name: AcceptanceTester
modules:
enabled:
- WebDriver
- \Helper\Acceptance
config:
WebDriver:
url: 'http://localhost'
browser: firefox
window_size: 820x1000
Codeception Version: 2.4.1
WebDriver Chrome Version: 2.38 (win32)
WebDriver Firefox Version: 0.20.1 (x64)
Chrome Version: 66.0.3359.139 (64-bit)
Firefox Version: Firefox Quantum 60.0 (64-bit)
Windows Version: Windows 8.1 64bit
Selenium Version: 3.12.0
To start Selenium Server you need not require to pass/specify the WebDriver variant and you can start the Selenium Server as follows :
Command :
>java -jar selenium-server-standalone-3.12.0.jar
Console Logs :
C:\Utility\selenium-server-standalone>java -jar selenium-server-standalone-3.12.0.jar
15:28:28.249 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.12.0', revision: '7c6e0b3'
15:28:28.251 INFO [GridLauncherV3$1.launch] - Launching a standalone Selenium Server on port 4444
2018-05-11 15:28:28.361:INFO::main: Logging initialized #467ms to org.seleniumhq.jetty9.util.log.StdErrLog
15:28:28.860 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
Snapshot of the Resource Hub :
Update
As per the documentation at codeception.com the acceptance.suite.yml should have been as follows :
modules:
enabled:
- WebDriver:
url: 'http://localhost/'
browser: firefox
window_size: 820x1000
Problem fixed. I was using proxy.
For future users with same problem like me, can follow the steps.
First, check if you have proxy defined with this command:
echo %http_proxy%
If return some result, you need set a empty proxy with this command:
set http_proxy=
You need define a proxy always you are opening a new command line.
I'm about to create an application full js based on vuejs. Following https://github.com/vuejs-templates/webpack, I have started a project:
$ vue init webpack my-project && cd my-project && yarn install
When I run unittest yarn run unit everything goes well, but when I run yarn run e2e which runs nightwatch.js, I get this error:
> Starting dev server...
Starting to optimize CSS...
> Listening at http://localhost:8889
Starting selenium server... started - PID: 23451
started - PID: 23451
[Test] Test Suite
=====================
Running: default e2e tests
[client :: capabilities] Test Suite
=======================================
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ Error: socket hang up
at createHangUpError (_http_client.js:344:15)
at Socket.socketOnEnd (_http_client.js:436:23)
at emitNone (events.js:110:20)
at Socket.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1047:12)
at _combinedTickCallback (internal/process/next_tick.js:102:11)
at process._tickCallback (internal/process/next_tick.js:161:9) code: 'ECONNRESET' }
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The selenium server is started on the fly when the e2e tests start and is shutdown when they finish. I'm sure because when I stop nightwatch.js before it fails I see :
$ ps aux | grep -i selenium
java -Dwebdriver.chrome.driver=node_modules/chromedriver/lib/chromedriver/chromedriver -jar node_modules/selenium-server/lib/runner/selenium-server-standalone-2.53.1.jar -port 4444
So the real error based on the output I get is mostlikely Error retrieving a new session from the selenium server. How do I fix this?
package.json
"chromedriver": "^2.27.2",
"cross-spawn": "^5.0.1",
"nightwatch": "^0.9.12",
"selenium-server": "^2.53.1",
test/e2e/nightwatch.conf.js
require('babel-register')
var config = require('../../config')
// http://nightwatchjs.org/gettingstarted#settings-file
module.exports = {
src_folders: ['test/e2e/specs'],
output_folder: 'test/e2e/reports',
custom_assertions_path: ['test/e2e/custom-assertions'],
selenium: {
start_process: true,
server_path: require('selenium-server').path,
host: '127.0.0.1',
port: 4444,
cli_args: {
'webdriver.chrome.driver': require('chromedriver').path
}
},
I recently started a Vue.js project with Webpack template. Your problem sounds familiar, but surprisingly, I forgot how I solved it...
The only difference I can see between your package.json and mine is the selenium-server version (^3.0.1). You should also check your Node version because Nightwatch is based on it. I remember that I had to update Node and npm for some reason (I do not use Yarn).
This is my environment (and it is working fine):
Node.js (v8.1.3)
npm (5.0.3)
Did you run node nightwatch.config.js, or node {whatever your nightwatch config file is called}. This will install Selenium and ChromeDriver correctly.