Proxy settings in nightwatch - nightwatch.js

I want to use nightwatch with a proxy.
In WebDriver Settings there is an option proxy, so I put:
"webdriver": {
"start_process": true,
"proxy": "http://134.119.205.244:8080"
},
but when running my test I get
An error occurred while retrieving a new session
at endReadableNT (_stream_readable.js:1142:12)
at processTicksAndRejections (internal/process/task_queues.js:81:17)
ยดยดยด
Any ideas?

Related

ECONNREFUSED using nightwatch-accessibility library

I'm trying to use the nightwatch-accessibility library, but keep getting error
POST /session/b4e18278544c74b9213c030b8119ee7e/timeouts/async_script - ECONNREFUSED
Error: connect ECONNREFUSED 127.0.0.1:9515
Error while running .setTimeoutsAsyncScript() protocol action: An unknown error has occurred.
POST /session/b4e18278544c74b9213c030b8119ee7e/execute_async - ECONNREFUSED
Error: connect ECONNREFUSED 127.0.0.1:9515
Error while running .executeScriptAsync() protocol action: An unknown error has occurred.
Normal tests work fine. As far as I can tell I am following the example correctly. The test assertions work correctly it just appears at the end of the test run.
nightwatch.json
{
"src_folders": ["test"],
"page_objects_path": "page-objects",
"globals_path": "./globals.js",
"custom_commands_path": ["./node_modules/nightwatch-accessibility/commands"],
"custom_assertions_path": ["./node_modules/nightwatch-accessibility/assertions"],
"end_session_on_fail": false,
"skip_testcases_on_fail": false,
"selenium": {
"start_process": false
},
"webdriver": {
"start_process": true,
"server_path": "node_modules/chromedriver/lib/chromedriver/chromedriver.exe",
"port": 9515
},
"test_settings": {
"default": {
"webdriver.port": 9515,
"desiredCapabilities": {
"browserName": "chrome"
}
}
}
}
globals.js
const chromedriver = require('chromedriver');
module.exports = {
before: function (done) {
chromedriver.start();
done();
},
after: function (done) {
chromedriver.stop();
done();
}
};
First test
module.exports = {
'#tags': ['accessibility'],
'First test': function (browser) {
browser
.url(`http://www.google.com`)
.pause(3000)
.initAccessibility()
.assert.accessibility('html', {
verbose: true
})
.end()
}
}
Executing by typing nightwatch from the terminal like I would other tests. Any ideas and is this the best accessibility assertion library for NightwatchJS?
I ended up using nightwatch-axe-verbose instead. Usage details included on this web accessibility testing using nightwatch blog post.

How do I use protractor with firefox and local self-signed https?

I'm using protractor to test an application and webdriver-manager doesn't seem to want to install an appropriate Chrome driver, so I'm trying Firefox instead. However, the test gets stuck at the security warning page of my self-signed https:// test server. How do I configure protractor / selenium webdriver to skip the warning page?
Use this block in your protractor.conf.js to load Firefox, and ignore the certificate error presented by the test server's self-signed certificate. Note that if you're editing a Chrome config it's not enough to change browserName, you must remove any chromeOptions: { to avoid confusing the test runner.
capabilities: {
browserName: 'firefox',
'moz:firefoxOptions': {
// command line options could go here
},
'acceptInsecureCerts': true
},
In order to run protractor tests on multiple browsers, Protractor
offers a multiCapabilities configuration option. These options should
be defined as an array of objects.
1. Capabilities to be passed to the web driver instance.
capabilities: {
'browserName': 'firefox',
},
2. How to execute protractor tests on multiple browsers in parallel using multiCapabilities.
multiCapabilities: [
{'browserName': 'chrome'},
{'browserName': 'firefox'},
],
3. How we can do it using multiCapabilities.
multiCapabilities: [
{
'browserName': 'chrome',
'chromeOptions': {
'args': ['disable-infobars']
}
},
{
'browserName': 'firefox',
'moz:firefoxOptions': {
'args': ['--safe-mode']
}
}
],

Nightwatchjs: how to solve Error retrieving a new session from the selenium server?

This is my part of my config:
"selenium": {
"start_process": true, // tells nightwatch to start/stop the selenium process
"server_path": "./selenium-server-standalone-3.8.1.jar",
"host": "127.0.0.1",
"port": 4444, // standard selenium port
"cli_args": {
"webdriver.chrome.driver": "./chromedriver_win32/chromedriver.exe"
}
},
test_settings" : {
"default" : {
"use_ssl": true,
"credentials": {
"username": "admin",
"key": "secret"
},
The test was running fine until I inserted use_ssl. Now I am getting this error:
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ Error: write EPROTO 101057795:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:797:
at exports._errnoException (util.js:1020:11)
at WriteWrap.afterWrite (net.js:800:14) code: 'EPROTO', errno: 'EPROTO', syscall: 'write' }
I am trying to test a page which requires windows authentication.

Webpack proxy not working

I'm now writing a vue project and I want to send some api requests to the remote server.
So I add this in my webpack.dev.conf.js:
devServer: {
historyApiFallback: true,
noInfo: true,
hot:true,
open:true,
proxy: {
'/api': {
target: 'http://47.93.247.233',
secure: false,
changeOrigin: true,
pathRewrite: {'^/api' : ''}
}
}
},
But I still get 404 in my browser.
And I'm sure the server is ok:
I think maybe the webpack devServer didn't forward my http request to the remote server. Is there anything wrong in my code? Or, can I try some other methods?
Thanks in advance!
Did you try to use
proxyTable: {...},
instead of
proxy{}
I'm running with webpack version 3.10.0 with npm v 5.6.0 and this works fine!
May be, you will try "logLevel: 'debug' too, to see some hints in your terminal window.

Karma proxies are not working

I am using Karma (v0.12.37) as test runner along with JSPM (v0.16.2). I have added following proxy config in karma so as to allow proper loading of JSPM files:
proxies: {
'/base/jspm_packages/': '/base/app/jspm_packages/'
}
Bu this doesn't work out and fails on following:
PhantomJS 2.0.0 (Windows 8 0.0.0) ERROR: 'Potentially unhandled rejection [10] Error: XHR error loading http://localhost:9876/base/jspm_packages/npm/babel-core#5.8.22.js
Error loading http://localhost:9876/base/jspm_packages/npm/babel-core#5.8.22.js
Error loading http://localhost:9876/base/app/pages/examples/todo-example/todo.controller.test.js'
Debug Logs are giving:
proxying request - /base/jspm_packages/npm/babel-core#5.8.22.js to localhost:9876
/base/app/jspm_packages/npm/babel-core#5.8.22.js { host: 'localhost',
port: 9876,
baseProxyUrl: '/base/app/jspm_packages/',
https: false }
But the following url containing 'app' in it works properly:
http ://localhost:9876/base/ app/ jspm_packages/npm/babel-core#5.8.22.js
Any clue on what is going wrong?
Try:
proxies: {
'/app/': '/base/app/',
'/jspm_packages/': '/base/jspm_packages/'
}
If you have configured your jspm-config with a baseUrl of "/", try removing the baseUrl entry since karma-jspm does not support a custom baseUrl. Then you should be able to get rid of the "proxies" entry for the jspm_packages.
See: https://github.com/Workiva/karma-jspm/issues/91
After having done lot of trial and error, found out the following way:
Instead of playing with proxies, alter the jspm paths config in karma.config.js
jspm: {
...
paths: {
"github:*": "app/jspm_packages/github/*",
"npm:*": "app/jspm_packages/npm/*",
'app/*': 'app/*.js'
},
...
},
What finally did the trick for me (karma, babel, JSPM/SystemJS) was to have this:
Remove baseUrl from the karma.conf.js and have this jspm section:
jspm: {
config: 'config.js',
loadFiles: [
'www/**/*.spec.js'
],
serveFiles: [
'www/**/!(*spec).js'
],
paths: {
"github:*": "/base/jspm_packages/github/*",
"npm:*": "/base/jspm_packages/npm/*",
'www/*': '/base/www/*'
}
},

Resources