We have written a bunch of e2e tests for an angular4 app, that we are developing. The problem is that I am getting random ECONNREFUSED message from webdriver / chrome, when running automated tests with protractor.
- Failed: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:54657
Protractor is running with shardedtestfiles turned on, and running with 12 browsers in parallel, in order to speed up testing.
I can't pinpoint an exact pattern to the errors that we get, so I am a bit lost here.. Below is a copy of the protractor config file, that we are using.
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
//*global jasmine */
"use strict";
var SpecReporter = require("jasmine-spec-reporter").SpecReporter;
var timeoutSettings = require('./dist/out-tsc/e2e/protractor.config').timeoutSettings
exports.config = {
allScriptsTimeout: 99999,
suites: {
spec: [
"./dist/out-tsc/e2e/spec/**/*spec.js"
]
},
capabilities: {
browserName: "chrome",
maxInstances: 12,
chromeOptions: {
args: ["--no-sandbox", "--disable-infobars", "--start-maximized", "--lang=DA-dk"],
prefs: {
download: {
promt_for_download: false,
default_directory: "spec/downloads" // To Do: Make sure this dir is correct!
},
"profile.password_manager_enabled": false,
credentials_enable_service: false,
password_manager_enabled: false
}
}
},
directConnect: true,
framework: "jasmine",
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 120000,
print: function () {}
},
SELENIUM_PROMISE_MANAGER: false,
useAllAngular2AppRoots: true,
beforeLaunch: function () {
require("ts-node").register({
project: "./e2e/tsconfig.json"
});
},
onPrepare: function () {
browser.manage().timeouts().implicitlyWait(timeoutSettings.implicitWaitNormal);
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
var trx = require("jasmine-trx-reporter");
return browser.getCapabilities().then(function (caps) {
var browserName = caps.get("browserName").toUpperCase();
var jasmineTrxConfig = {
reportName: "Protractor Test Results",
folder: "reports",
outputFile: "",
browser: "GANDALF_" + browserName,
groupSuitesIntoSingleFile: false,
takeScreenshotsOnlyOnFailures: false
};
jasmine.getEnv().addReporter(new trx(jasmineTrxConfig));
});
}
};
It seems that this is actually a problem in the version of selenium webdriver, that is pulled in, when using protractor
There is a discussion in an issue with protractor on github
https://github.com/angular/protractor/issues/4792
Related
I am following https://docs.aws.amazon.com/lambda/latest/dg/images-create.html and created an image from an AWS base image for Lambda and tested it locally first before pushing it to ECR. On invoking function locally, I get expected results i.e. Error Code 0. But after pushing image on ECR and invoking it from AWS lambda console, I get following issue.
START RequestId: 55930a26-5d88-4d1f-9a5b-14599b369585 Version: $LATEST
[04:46:19] I/launcher - Running 1 instances of WebDriver
[04:46:19] I/direct - Using ChromeDriver directly...
[04:46:22] E/runner - Unable to start a WebDriver session.
[04:46:22] E/launcher - Error: NoSuchSessionError: invalid session id
at Object.throwDecodedError (/var/task/node_modules/selenium-webdriver/lib/error.js:514:15)
at parseHttpResponse (/var/task/node_modules/selenium-webdriver/lib/http.js:519:13)
at /var/task/node_modules/selenium-webdriver/lib/http.js:441:30
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Promise.all (index 0)
[04:46:22] E/launcher - Process exited with error code 100
2021-08-11T04:46:22.089Z 55930a26-5d88-4d1f-9a5b-14599b369585 INFO error code: 100
END RequestId: 55930a26-5d88-4d1f-9a5b-14599b369585
REPORT RequestId: 55930a26-5d88-4d1f-9a5b-14599b369585 Duration: 9465.93 ms Billed Duration: 10270 ms Memory Size: 10000 MB Max Memory Used: 314 MB Init Duration: 803.88 ms
My conf.js
exports.config = {
directConnect: true,
ignoreUncaughtExceptions: true,
SELENIUM_PROMISE_MANAGER: false,
'specs': ['index.js'],
jasmineNodeOpts: {
defaultTimeoutInterval: 1000 * 6,
realtimeFailure: true,
showColors: true,
isVerbose: true,
includeStackTrace: true,
displaySpecDuration: true,
print: function () {},
},
'capabilities': {
'browserName': 'chrome',
acceptInsecureCerts: true,
acceptSslCerts: true,
chromeOptions: {
binary: "/usr/bin/google-chrome",
"excludeSwitches": [ "enable-automation" ],
"useAutomationExtension": false,
args: ["--no-sandbox","--disable-web-security","--headless","--disable-dev-shm-usage","--disable-extensions", "--disable-gpu", "--start-maximized", "--disable-infobars"]
}
},
framework: "jasmine"
};
My package.json
{
"name": "protractor",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "node_modules/.bin/protractor conf.js",
"runlocal": "node_modules/.bin/sls invoke local --function protractor",
"deploy": "node_modules/.bin/sls deploy"
},
"author": "",
"license": "ISC",
"dependencies": {
"jasmine": "^3.8.0",
"npm": "^6.14.14",
"protractor": "^7.0.0",
"protractor-beautiful-reporter": "^1.3.6"
}
}
My dockerfile
FROM amazon/aws-lambda-nodejs:12
COPY index.js conf.js handler.js package*.json screenshots ./
ADD install-google-chrome.sh .
RUN chmod +x install-google-chrome.sh
RUN curl https://intoli.com/install-google-chrome.sh | bash
ADD gtk-firefox.sh .
RUN chmod 755 gtk-firefox.sh
RUN ./gtk-firefox.sh
RUN npm install
RUN node ./node_modules/protractor/bin/webdriver-manager clean
RUN node ./node_modules/protractor/bin/webdriver-manager update
CMD [ "handler.runtest" ]
handler.js
'use strict';
module.exports.runtest = (event, context, callback) => {
var npm = require('npm');
var path = require('path');
var childProcess = require('child_process');
var args = ['conf.js'];
npm.load(function() {
var child = childProcess
.fork(path.join(npm.root, 'protractor/bin/protractor'), args)
.on('close', function(errorCode) {
console.log('error code: ', errorCode);
// Use this block to have Lambda respond when the tests are done.
const response = {
statusCode: 200,
body: JSON.stringify({
message: `Selenium Test executed on Chrome ! Child process Error Code: ${errorCode}`,
}),
};
callback(null, response);
});
process.on('SIGINT', child.kill);
});
};
index.js
const {by} = require("protractor");
const {protractor} = require("protractor");
const {browser} = require("protractor");
describe('Google\'s Search Functionality', function() {
it('can find search results', async function() {
const signin = "Sign in"
await browser.waitForAngularEnabled(false);
await browser.get('https://google.com/ncr');
await browser.findElement(by.name('q')).sendKeys('BrowserStack', protractor.Key.ENTER);
const texti = browser.findElement(by.xpath('//a[contains(#href,"sign_in")]'));
expect(await texti.getText()).toEqual(signin);
});
});
Al these files are at same level in root project directory.
I googled a lot but not able to find proper resolution. Is it some permission issue?
As I don't understand what makes the same lambda container image fail in lambda console and not in local.
I am just wondering if it is possible to run two different specs at the same time using protractor.
My protractor.config.js is below:
var browserCapabilities = [
{
browserName: 'chrome',
maxInstances: 2,
seleniumAddress: seleniumServer,
platform: 'ANY',
version: 'ANY',
chromeOptions: {
args: ['--no-sandbox', '--test-type=browser', '--lang=en', '--window-size=1680,1050'],
prefs: {
'credentials_enable_service': false,
'profile': {
'password_manager_enabled': false
},
download: {
prompt_for_download: false,
directory_upgrade: true,
default_directory: 'C:\\downloads\\'
},
},
},
loggingPrefs: { browser: 'SEVERE' }
},
];
// Protractor config
exports.config = {
baseUrl: baseUrl,
directConnect: false,
allScriptsTimeout: 25 * 1000,
jasmineNodeOpts: {
defaultTimeoutInterval: 90 * 1000
},
getPageTimeout: 120 * 1000,
suites: {
adminRoles: 'compiled/artemis/settings/adminAppRoles.scenario.js',
adminUsers: 'compiled/artemis/settings/adminUsers.scenario.js',
benchmarks: 'compiled/artemis/benchmarks/benchmark.scenario.js',
claims: 'compiled/artemis/claims/claims.scenario.js',
cohorts: 'compiled/artemis/cohorts/cohort.scenario.js',
customBD: 'compiled/artemis/dimensions/*.scenario.js',
exploreCreate: 'compiled/artemis/explorations/create.scenario.js',
exploreInMeasureFilters: 'compiled/artemis/explorations/inMeasureFilters.scenario.js',
exploreRead: 'compiled/artemis/explorations/read.scenario.js',
exploreRegFilters: 'compiled/artemis/explorations/regularFilters.scenario.js',
exploreUpdate: 'compiled/artemis/explorations/update.scenario.js',
home: 'compiled/artemis/home/home.scenario.js',
login: 'compiled/artemis/login/*.scenario.js',
mgmtConsole: 'compiled/artemis/settings/mgmtConsoleSysDef.scenario.js',
navigation: 'compiled/artemis/navigation/navigation.scenario.js',
sharing: 'compiled/artemis/sharing/sharingTests.scenario.js',
smoke: 'compiled/artemis/smokeTests/smokeTests.scenario.js',
stories: 'compiled/artemis/story/story.scenario.js',
visualizeCreate: 'compiled/artemis/visualize/visualizeCreate.scenario.js',
visualizeRead: 'compiled/artemis/visualize/visualizeRead.scenario.js',
visualizeUpdate: 'compiled/artemis/visualize/visualizeUpdate.scenario.js',
vizInMeasureFilters: 'compiled/artemis/visualize/vizInMeasureFilters.scenario.js',
vizRegFilters: 'compiled/artemis/visualize/vizRegularFilters.scenario.js',
tritonLogin: 'compiled/triton/login/*.scenario.js',
tritonCustomers: 'compiled/triton/customers/*.scenario.js',
tritonDashboard: 'compiled/triton/dashboard/*.scenario.js'
},
multiCapabilities: browserCapabilities,
framework: 'jasmine2',
onPrepare: function() {
//Set Up a JUnit XML Reporter - Makes a nice test results area and trend graph in Jenkins
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: 'report',
filePrefix: 'xmloutput'
}));
const JasmineConsoleReporter = require('jasmine-console-reporter');
const consoleReporter = new JasmineConsoleReporter({
colors: 1,
cleanStack: 1,
verbosity: 4,
listStyle: 'indent',
activity: true,
emoji: true,
beep: true
});
//Setup screenshots
jasmine.getEnv().addReporter(screenShotReporter);
jasmine.getEnv().addReporter(consoleReporter);
browser.get(browser.baseUrl);
},
// Setup the report before any tests start
beforeLaunch: function() {
return new Promise(function(resolve) {
screenShotReporter.beforeLaunch(resolve);
});
},
// Close the report after all tests finish
afterLaunch: function(exitCode) {
return new Promise(function(resolve) {
screenShotReporter.afterLaunch(resolve.bind(this, exitCode));
});
},
};
I launch my tests with a command like this:
gulp e2e --suite suiteName --baseUrl http://myurl.com/
I would like to be able to for example launch my login suite and my navigation suite at the same time.
I have tried the maxInstances: 2 in the browserCapabilities variable, but that only launched the login suite.
I have tried doing two instances of the chrome object and then doing maxSessions: 2 but that only launched the login test twice.
I am envisioning a command like this: gulp e2e --suite login --suite navigation --baseUrl http://myurl.com and having it launch both suites simultaneously.
U can use shardTestFiles: true
// ...
capabilities: {
shardTestFiles: true,
maxInstances: 2,
// ...
I am trying to make task for creating favicon images in GULP like this
var realFavicon = require ('gulp-real-favicon');
var fs = require('fs');
// File where the favicon markups are stored
var FAVICON_DATA_FILE = 'faviconData.json';
// Generate the icons. This task takes a few seconds to complete.
// You should run it at least once to create the icons. Then,
// you should run it whenever RealFaviconGenerator updates its
// package (see the check-for-favicon-update task below).
gulp.task('generate-favicon', function(done) {
realFavicon.generateFavicon({
masterPicture: 'TODO: Path to your master picture',
dest: 'TODO: Path to the directory where to store the icons',
iconsPath: '/',
design: {
ios: {
pictureAspect: 'noChange'
},
desktopBrowser: {},
windows: {
pictureAspect: 'noChange',
backgroundColor: '#da532c',
onConflict: 'override'
},
androidChrome: {
pictureAspect: 'shadow',
themeColor: '#ffffff',
manifest: {
name: 'MyApp',
display: 'browser',
orientation: 'notSet',
onConflict: 'override'
}
},
safariPinnedTab: {
pictureAspect: 'silhouette',
themeColor: '#5bbad5'
}
},
settings: {
scalingAlgorithm: 'Mitchell',
errorOnImageTooSmall: false
},
markupFile: FAVICON_DATA_FILE
}, function() {
done();
});
});
// Inject the favicon markups in your HTML pages. You should run
// this task whenever you modify a page. You can keep this task
// as is or refactor your existing HTML pipeline.
gulp.task('inject-favicon-markups', function() {
gulp.src([ 'TODO: List of the HTML files where to inject favicon markups' ])
.pipe(realFavicon.injectFaviconMarkups(JSON.parse(fs.readFileSync(FAVICON_DATA_FILE)).favicon.html_code))
.pipe(gulp.dest('TODO: Path to the directory where to store the HTML files'));
});
// Check for updates on RealFaviconGenerator (think: Apple has just
// released a new Touch icon along with the latest version of iOS).
// Run this task from time to time. Ideally, make it part of your
// continuous integration system.
gulp.task('check-for-favicon-update', function(done) {
var currentVersion = JSON.parse(fs.readFileSync(FAVICON_DATA_FILE)).version;
realFavicon.checkForUpdates(currentVersion, function(err) {
if (err) {
throw err;
}
});
});
Only problem I have is that i dont have faviconData.json can somebody share his, txanks
You should go back to Real Favicon Generator and follow the installation steps. Basically:
Replace the "TODO" in the generated code with actual paths.
Run gulp generate-favicon. This once-in-a-while task generates your icons and also the faviconData.json file you miss. For example this file contains the HTML markups that declare the icons.
Now you are ready to run gulp inject-favicon-markups whenever you deploy your site, update one of your pages, etc.
"favicons": {
"files": {
"src": "./dist/img/logo/favicon.png",
"dest": "./dist/img/favicons/",
"html": "./templates/misc/favicons.tpl.php",
"iconsPath": "./dist/img/favicons/",
"androidManifest": null,
"browserConfig": null,
"firefoxManifest": null,
"yandexManifest": null
},
"icons": {
"android": true,
"appleIcon": true,
"appleStartup": true,
"coast": true,
"favicons": true,
"firefox": true,
"opengraph": true,
"windows": true,
"yandex": true
},
"settings": {
"appName": "name",
"appDescription": "This is the app description",
"developer": null,
"developerURL": null,
"version": 1.0,
"background": null,
"index": null,
"url": null,
"silhouette": false,
"logging": true
},
"favicon_generation": null
},
maybe you can use this, you should change the settings of course :)
Guys
I made a simple easyXDM code, it do not work on IE8, but works fine in all the other browsers, please help to find if I made any mistakes in my code.
(I got access denied error in IE8).
Local Domain:
$(document).ready(function(){
var rpc = new easyXDM.Rpc({
'local': "lib/name.html",
'remote': "http://10.74.80.70:1291/XDMtest/query.html",
'remoteHelper': "http://10.74.80.70:1291/XDMtest/name.html",
'lazy': false,
'timeout': 10 * 1000,
'swf': "lib/easyxdm.swf",
'swfNoThrottle': true,
'container': 'embeded'
},{
'remote': {
XDMquery:{}
},
'local':{
getReturn: function(response,callback){
// pass response into callback's parameter
callback(response);
}
}
});
rpc.XDMquery({
"url": "http://10.74.80.70:1291/api/product/GetAllProducts",
"method":"GET",
'dataType': 'json',
'contentType': 'application/json; charset=utf-8',
"crossDomain": true
},function(response){
console.log(response);
$("h1").text(response.status)
});
});
Remote Domain:
var xhr;
var internalQuery = function(queryObj,callback){
$.ajax(queryObj).complete(function(response){
xhr.getReturn(response,callback);
})
}
$(document).ready(function(){
xhr = new easyXDM.Rpc(
{
"local": "lib/query.html",
"swf": "lib/easyxdm.swf",
"swfNoThrottle": true
},
{
"local": {
XDMquery: function(obj,callback){
internalQuery(obj,callback);
}
},
"remote":{
getReturn: {}
}
}
);
});
The problem is coming from jquery library, if change to jquery1.10.0 in remote server, this problem can be fixed.
I am new to AngularJS. I'm trying to run end-to-end tests with Protractor. Currently, I am running my tests from grunt with help from grunt-protractor-runner. My base test looks like the following:
describe('My Tests', function () {
var p = protractor.getInstance();
beforeEach(function () {
});
it('My First Test', function () {
var message = "Hello!";
expect(message).toEqual('Hello!');
});
});
This works just fine. However, it really doesn't test my app. To do that I always want to start in the root of the app. In an attempt to do this, I've updated the above to the following:
describe('My Tests', function () {
var p = protractor.getInstance();
beforeEach(function () {
p.get('#/');
});
it('My First Test', function () {
var message = "Hello!";
expect(message).toEqual('Hello!');
});
});
When this test gets ran, Chrome launches. However, "about:blank" is what gets loaded in the address bar. My app never loads. I've reviewed my protractor.config.js file and it looks correct. It looks like the following:
exports.config = {
allScriptsTimeout: 110000,
seleniumServerJar: './node_modules/protractor/bin/selenium/selenium-server-standalone-2.37.0.jar',
seleniumPort: 1234,
seleniumArgs: [],
seleniumAddress: null,
chromeDriver: './node_modules/protractor/bin/selenium/chromedriver.exe',
capabilities: { 'browserName': 'chrome' },
specs: [ '../tests/**/*.spec.js' ],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
}
};
How do I get my app to load into Chrome for the purpose of an integration test via protractor?
Perhaps you've already figured out how to get it working, but if not maybe the following will help (modify the port if necessary of course):
// A base URL for your application under test. Calls to protractor.get()
// with relative paths will be prepended with this.
baseUrl: 'http://localhost:3000'
Add this property to your protractor.config.js file.
Reference: https://github.com/angular/protractor/blob/master/referenceConf.js