chromedriver Only local connections are allowed - protractor

I try to start tests by webdriver-manager and protractor.
Verify versions:
Google Chrome 73.0.3683.86
ChromeDriver 73.0.3683.68
start webdriver-manager webdriver-manager start
and start protractor
I got error by protractor
enviroment: test
[12:20:23] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[12:20:23] E/driverProvider - Error code: 135
[12:20:23] E/driverProvider - Error message: unknown error: Chrome failed to start: exited abnormally
[12:20:23] E/driverProvider - Error: unknown error: Chrome failed to start: exited abnormally
(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.)
(Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Linux 4.9.0-8-amd64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 172 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'dev', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.0-8-amd64', java.version: '1.8.0_212'
Driver info: driver.version: unknown
at Hosted.<anonymous> (/usr/lib/node_modules/protractor/built/driverProviders/driverProvider.js:69:23)
at Generator.throw (<anonymous>)
at rejected (/usr/lib/node_modules/protractor/built/driverProviders/driverProvider.js:5:65)
at process._tickCallback (internal/process/next_tick.js:68:7)
[12:20:23] E/launcher - Process exited with error code 135
and info by webdriver-manager
12:19:38.934 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"count": 1
}
12:19:38.947 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72) on port 15966
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
protractor.conf.js in project folder (where I execute command protractor --host https://MySite
let test_url = '';
let enviroment = process.env.NODE_ENV;
console.log('enviroment:', enviroment);
//console.log('process.env:', process.env);
let settings = {
seleniumAddress: 'http://localhost:4444/wd/hub',
//directConnect: true,
specs: ['./e2e/todo-spec.js'],
// Options to be passed to Jasmine-node.
params: {
host: 'http://localhost:3000'
},
capabilities: {
browserName: 'chrome'
},
onPrepare: function() {
// The require statement must be down here, since jasmine-reporters#1.0
// needs jasmine to be in the global and protractor does not guarantee
// this until inside the onPrepare function.
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(
new jasmineReporters.JUnitXmlReporter('xmloutput', true, true)
);
},
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
}
}
if(process.env.hasOwnProperty('npm_config_host') && process.env.npm_config_host){
settings.params.host = process.env.npm_config_host
}
exports.config = settings;

In your chromeOptions, can you try adding --no-sandbox and --disable-dev-shm-usage and then try running the tests . Also try downgrading the browser version to see if the code is working as expected.
"chromeOptions": {
"args": ['--no-sandbox','--disable-dev-shm-usage'],

Remove seleniumAddress: fomr your config and add the below one.
exports.config = {
directConnect: true,
}
When you add dirctConnect=true you don't need to start the webdriver separately.
Hope it help you

Please make sure you have
127.0.0.1 localhost
in your /etc/hosts file.
To check it, you should go to the terminal and run
sudo vi /etc/hosts
type your user password and paste
127.0.0.1 localhost
to an empty row.
Additionally, please make sure you have ChromeDriver -or the driver of the browser you intend to use- is installed and your program knows the path of ChromeDriver.
You can follow the steps explained here https://www.browserstack.com/guide/run-selenium-tests-using-selenium-chromedriver.

Related

When I run protractor tests why do i get SSL routines:ssl3_get_record:wrong version number?

SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:
My spec is:
describe('Protractor Demo App', function() {
it('should have a title', function() {
browser.get('http://google.com/'); // <-- not https! (though I did try it!)
expect(browser.getTitle()).toEqual('Google');
});
});
Whatever URL address I try I get this error
$ protractor conf.js
[12:59:46] I/launcher - Running 1 instances of WebDriver
[12:59:46] I/hosted - Using the selenium server at https://localhost:4444/wd/hub
[12:59:46] E/launcher - EPROTO write EPROTO 140666782832512:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:
[12:59:46] E/launcher - Error: EPROTO write EPROTO 140666782832512:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:
at ClientRequest.<anonymous> (/home/durrantm/Dropbox/90_2019/work/code/js/protractor/protractortest.org/node_modules/selenium-webdriver/http/index.js:238:15)
at ClientRequest.emit (events.js:223:5)
at TLSSocket.socketErrorListener (_http_client.js:406:9)
at TLSSocket.emit (events.js:223:5)
In another window I have server running
12:43:28.246 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
and in a browser you can see
The problem was in config.js
I had
seleniumAddress: 'https://localhost:4444/wd/hub',
but I needed:
seleniumAddress: 'http://localhost:4444/wd/hub'

Protractor - log type 'performance' not found error

webdriver-manager 12.1.5
protractor Version 5.4.2
Chrome version 75.0.3770.100
browser.manage().logs().get('performance');
This used to work fine before upgrading my webdriver-manager and protractor version.
(node:27715) UnhandledPromiseRejectionWarning: WebDriverError: invalid argument: log type 'performance' not found
(Session info: chrome=75.0.3770.100)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info:, os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.4', java.version: '1.8.0_191'
Driver info: driver.version: unknown
at Object.checkLegacyResponse (node_modules/selenium-webdriver/lib/error.js:546:15)
If I comment the browser.manage().logs().get('performance'); and other performance related code, then the test runs fine.
webdriver-manager logs show:
Starting ChromeDriver 75.0.3770.90 on port 12268
I came across a potential solution on this github issue thead. Apparently recently chromedriver has started to more strictly adhere to W3C standards and this has affected how webdriver activates logs.
We can get around this issue by setting the w3c: false flag in chromeoptions like so.
capabilities: {
browserName: 'chrome',
loggingPrefs: {
browser: 'ALL',
driver: 'ALL',
performance: 'ALL',
},
'goog:chromeOptions': {
perfLoggingPrefs: {
enableNetwork: true,
},
w3c: false,
},
},
New version might not support performance log type. You can always use getAvailableLogTypes function to check supported log types. I tried following code
var supportedLogTypes = await browser.manage().logs().getAvailableLogTypes();
received ouptput :
It means you can only use either of two supported log types.
I tried out the same thing with chrome 75.* and protractor 5.4.2 version. Following are my findings.
loggingPrefs object is one of the recognized capabilities like chromeOptions. This object allow us to decide preferences on logging part. Refer link for more details about capabilities.
In protractor context we have to pass loggingPrefs object to capabilities to enable it.
Once we pass it then we can use browser.manage().logs().get('performance'); to get all performance logs.
If you want to change perfLoggingPrefs then it is part of chromeOptions object and it has to be updated there. If we want to use default then no need to mention.
chrome use more strictly rule for w3c, when I test chrome driver 96, set w3c to false, I can get network log, but find_element failed and return dict value which is not WebElement

How to run Protractor specs on IE 11?

I have been trying to run protractor specs on IE 11,with following conf.js:
multiCapabilities: [
{
'browserName': 'internet explorer',
version: 11,
'ignoreProtectedModeSettings': true
// 'idle-duration':10000,
},
}],
And added this as well:
seleniumArgs: 'C:/Users/LJQAuser/AppData/Roaming/npm/node_modules/protractor/node_modules/webdriver-manager/selenium/IEDriverServer.exe',
And set directConnect to : false
But still its showing error:
Error in console is:
[12:38:42] I/local - Starting selenium standalone server...
[12:38:43] E/launcher - Error: Error: Server terminated early with status 1
at earlyTermination.catch.e (C:\Users\LJQAuser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\remote\index.js:252:52)
at :null:null
at process._tickCallback (internal/process/next_tick.js:188:7)
Closing report
[12:38:43] E/launcher - Process exited with error code 100
There is tons of issues with internet explorer. Probably you wont be able to run it successfully.
There is alot of manual steps also to be applied.
Here is some basic guide how to setup:
Protractor test in IE
https://qavalidation.com/2017/11/run-protractor-test-ie-internet-explorer.html/
Good luck!

ECONNREFUSED Webdriver errors in eclipse when running Protractor

So, I was following this tutorial on getting my existing protractor files imported to Eclipse as Java project, installing angular/protractor configurations on eclipse and running the files:
https://www.youtube.com/watch?v=8dZ3isYcthI
But then I got into the weeds on this error: Error while running conf.js file from Eclipse
In attempt to resolve it, following instructions on the youtube tutorial, I replaced the selenium webdriver folder in Eclipse with the selenium webdriver folder in my node modules folder in AppData by dragging and dropping
Now my conf.js file will not run as protractor on Eclipse even though the file will execute successfully from the command line. Error is:
(node:53640) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[15:11:38] I/launcher - Running 1 instances of WebDriver
[15:11:38] I/hosted - Using the selenium server at http://localhost:4444 /wd/hub
[15:11:39] E/launcher - Error code: 135
[15:11:39] E/launcher - Error message: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444
[15:11:39] E/launcher - Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444 at ClientRequest. (C:\Workspace\testUltimateQASite\node_modules\selenium-webdriver\http\index.js:238:15)
The js line it is pointing to in the index file is the last line of this function:
request.on('error', function(e) {
if (e.code === 'ECONNRESET') {
setTimeout(function() {
sendRequest(options, onOk, onError, opt_data, opt_proxy);
}, 15);
} else {
var message = e.message;
if (e.code) {
message = e.code + ' ' + message;
}
onError(new Error(message));
}
});
My conf.js file is as follows:
// conf.js
//var jasmineReporters = require('jasmine-reporters');
var os = require('os'); os.tmpDir = os.tmpdir;
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['qaSpec.js'],
//module.exports = {
params: {
url : 'http://phptravels.com/demo/'
/* login: {
url: 'http://phptravels.com/demo/',
username: 'juliel#ibm.com',
password: 'password'
}*/
}
};
The error is basically stating that your Selenium server doesn't seem to be running. Notice how you are seeing a connection refused error.
Please check if you have started the selenium server as described in the official documentation here : http://www.protractortest.org/#/tutorial#setup
For more information on setting up eclipse and protractor you might want to refer here as well :https://github.com/angelozerr/angularjs-eclipse/wiki/Protractor
I tried to understand your project's architecture by reading post several times and still got a bit confused.
I am not sure how do you manage Webdriver?
For Protractor project I would recommend using proper NodeJS project's structure as well as using any JS task runner. Grunt might be a good choice.
There are plenty Webdriver Manager plugins as well as Protractor managers so you will be able to load your project's dependencies and run test with single Grunt command.
UPDATE: this demo project might be useful in understanding the use of Grunt and its dependencies in Angular project's architecture.

Protractor does not close browser when a server is unavailable

I do e2e testing with protractor. When my application is running on a server the tests pass fine and a browser is closed afterward, however when the server is down the browser remains (Firefox, Chrome). It is OK on my local machine but I am experimenting with running tests on remote CI machine and afraid that the tests can spawn multiple browser windows if the server fails to run. How to make sure protractor closes the browser window in such situation?
Here is my configuration:
exports.config = {
allScriptsTimeout: 11000,
specs: [
'../test/e2e/*.js'
],
capabilities: {
'browserName': 'firefox'
},
baseUrl: 'http://localhost:8000/',
framework: 'jasmine',
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
};
and the test is:
'use strict';
describe('typicaClient', function() {
browser.get('index.html');
it('test', function() {
expect('str').toMatch('str');
});
});
Protractor leaves browser open on those errors which it doesn't recognize and cannot handle.
Check out the example below. This error thrown by spawn() process is unhandled by Protractor and it exits with an error code - 199
describe('sample test', function(){
it('Sample Check', function(){
browser.get("http://www.protractortest.org/#/");
browser.sleep(5000);
var terminal = require('child_process').spawn('34e3545')
});
});
Output:
[18:26:46] I/local - Starting selenium standalone server...
[18:26:46] I/launcher - Running 1 instances of WebDriver
[18:26:46] I/local - Selenium standalone server started at http://192.168.1.5:61146/wd/hub
Started
[18:26:49] E/launcher - spawn 34e3545 ENOENT
[18:26:49] E/launcher - Error: spawn 34e3545 ENOENT
at exports._errnoException (util.js:873:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
at onErrorNT (internal/child_process.js:344:16)
at nextTickCallbackWith2Args (node.js:442:9)
at process._tickCallback (node.js:356:17)
[18:26:49] E/launcher - Process exited with error code 199
To avoid these , handle gracefully the error at non-protractor commands
describe('sample test', function(){
it('Sample Check', function(){
browser.get("http://www.protractortest.org/#/");
browser.sleep(5000);
var terminal = require('child_process').spawn('34e3545').on('error', function(err) {
fail('Test is failing because we provided an invalid process')
});
});
});
Output in this case:
[18:57:22] I/local - Starting selenium standalone server...
[18:57:22] I/launcher - Running 1 instances of WebDriver
[18:57:22] I/local - Selenium standalone server started at http://192.168.1.5:49867/wd/hub
Started
F
Failures:
1) sample test Sample Check
Message:
Failed: Test is failing because we provided an invalid process
Stack:
Error: Failed: Test is failing because we provided an invalid process
at ChildProcess.<anonymous> (C:\Users\ayannam\WebstormProjects\demo\errorHandle.js:7:13)
at emitOne (events.js:77:13)
at ChildProcess.emit (events.js:169:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
1 spec, 1 failure
Finished in 6.582 seconds
See it this case Un-handled exception is handled and Protractor throws an error code - 1 which is gracefully handled