Server side error while executing the script in appium - protractor

I was trying to execute the appium script in an virtual emulator.But while executing i am getting this below error.In emulator the app is launched but it doesn't perform any action gets closed.
Error:-
[16:52:46] E/launcher - An unknown server-side error occurred while processing the command. Original error: No Chromedriver found that can automate Chrome '77.0.3865'. See https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/web/chromedriver.md for more details. You could also try to enable automated chromedrivers download server feature
[16:52:46] E/launcher - WebDriverError: An unknown server-side error occurred while processing the command. Original error: No Chromedriver found that can automate Chrome '77.0.3865'. See https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/web/chromedriver.md for more details. You could also try to enable automated chromedrivers download server feature
[16:52:46] E/launcher - Process exited with error code 199
Conf File:-
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 300000,
seleniumAddress: 'http://localhost:4723/wd/hub',
specs: [
'./e2e/**/login.mobile.ts',
],
useAllAngular2AppRoots: true,
//chromeDriver: './node_modules/chromedriver/lib/chromedriver/chromedriver.exe',
capabilities: {
platformName: 'Android',
platformVersion: '9',
deviceName: 'emulator-5554',
browserName: '',
appiumVersion:'1.16.0',
autoWebview: true,
autoWebviewTimeout: 10000,
autoacceptalerts: true,
autoGrantPermissions: true,
clearSystemFiles: true,
app: './platforms/android/build/outputs/apk/android-debug.apk
},
//baseUrl: 'http://10.0.2.2:8000',
plugins: [
{
path: require.resolve('protractor-console'),
logLevels: ['severe'],
package: 'jasmine2-protractor-utils',
disableHTMLReport: false,
disableScreenshot: false,
screenshotPath: './screenshots',
screenshotOnExpectFailure: true,
screenshotOnSpecFailure: true,
clearFoldersBeforeTest: true
}
],
// directConnect: true, //enable for desktop
//baseUrl: 'http://localhost:4723/wd/hub',
framework: 'jasmine2',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 300000,
print: function() {}
},
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
},
onPrepare() {
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(
new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: './report/mobile',
filePrefix: 'xmlresults'
})
);
var wd = require('wd'),
protractor = require('protractor'),
wdBridge = require('wd-bridge')(protractor, wd);
wdBridge.initFromProtractor(exports.config);
},
onComplete: function() {
var browserName, browserVersion;
var capsPromise = browser.getCapabilities();
capsPromise.then(function(caps) {
browserName = caps.get('browserName');
browserVersion = caps.get('version');
var HTMLReport = require('protractor-html-reporter');
testConfig = {
reportTitle: 'CVM Test Execution Report',
outputPath: './report/mobile', //relative path
screenshotPath: './screenshots',
testBrowser: 'Mobile',
browserVersion: browserVersion,
modifiedSuiteName: false,
screenshotsOnlyOnFailure: true
};
new HTMLReport().from('./report/mobile/xmlresults.xml', testConfig);
});
}
};

Related

Protractor - headless execution for parallel test is failing

Trying to run two instances of webdriver with headless chrome browser.
Getting below error when ran with protractor-beautiful-reporter
I/runnerCli - ENOENT: no such file or directory, unlink 'Results/Jsons/000000d8-003c-0046-00f3-00a30045006c.json'
conf.js
let HtmlReporter = require('protractor-beautiful-reporter');
exports.config = {
framework: 'jasmine',
directConnect: true,
allScriptsTimeout: 900000,
getPageTimeout: 120000,
onPrepare: function () {
jasmine.getEnv().addReporter(new HtmlReporter({
filename: 'MVP.html',
baseDirectory: 'Results',
preserveDirectory: false,
takeScreenShotsOnlyForFailedSpecs: true,
screenshotsSubfolder: 'Screenshots',
jsonsSubfolder: 'Jsons',
docTitle: 'PM UI Test Result',
sortFunction: function sortFunction(a, b) {
if (a.instanceId < b.instanceId) return -1;
else if (a.instanceId > b.instanceId) return 1;
if (a.timestamp < b.timestamp) return -1;
else if (a.timestamp > b.timestamp) return 1;
return 0;
},
clientDefaults: {
showTotalDurationIn: 'belowHeader',
totalDurationFormat: 'hms'
}
}).getJasmine2Reporter());
},
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ["--headless", "--window-size=1920,1200"]
},
acceptSslCerts: true,
trustAllSSLCertificates: true,
acceptInsecureCerts: true,
ACCEPT_SSL_CERTS: true,
maxInstances: 2,
shardTestFiles: true
},
jasmineNodeOpts: {
defaultTimeoutInterval: 900000,
},
specs: ['../tests/abc.js',
'../tests/xyz.js'
],
};

grunt-protractor-runner: Unable to pick scenarios

I'm trying to create grunt tasks using grunt-protractor-runner with my protractor-cucumber framework. Below is how the Gruntfile.js looks like:
grunt.initConfig({
protractor: {
options: {
//configFile: "./config/config.js",
keepAlive: true,
noColor: false,
},
chrome: {
options: {
configFile: "./config/config.js",
args: {
autoConnect: false,
seleniumServerJar: './node_modules/webdriver-manager/selenium/selenium-server-standalone-3.141.59.jar',
chromeDriver: './node_modules/webdriver-manager/selenium/chromedriver.exe',
specs: [
'../features/calendar.feature',
'../features/deal.feature',
'../features/entitlement.feature',
'../features/filter.feature',
'../features/product.feature'
],
capabilities: {
browserName: 'chrome',
chromeOptions: {
useAutomationExtension: false,
args: ['–disable-gpu'],
}
}
}
}
}
},
});
grunt.registerTask('test', ['protractor:chrome']);
If I run command grunt test it opens the chrome browser and closes with the below log:
Running "protractor:chrome" (protractor) task
[17:22:57] I/launcher - Running 1 instances of WebDriver
[17:22:57] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
0 scenarios
0 steps
0m00.000s
This doesn't pick any scenarios to run. Can you help me to understand what's the issue here? My config.conf looks like this:
const Reporter = require('../support/Reporter.js');
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
autoConnect: false,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
restartBrowserBetweenTests: false,
SELENIUM_PROMISE_MANAGER: true,
ignoreUncaughtExceptions: true,
onPrepare: function () {
browser.ignoreSynchronization = false;
browser.manage().timeouts().setScriptTimeout(40 * 1000);
browser.manage().timeouts().implicitlyWait(4 * 1000);
browser.manage().window().maximize();
require('babel-register');
},
cucumberOpts: {
strict: true,
format: ['json:./reports/json/cucumber_report.json'],
require: ['../support/*.js', '../stepDefinitions/*.js', '../stepDefinitions/*.ts'],
tags: 'not #Ignore', //(#CucumberScenario or #ProtractorScenario) and (not #Ignore)
retry: 3
},
params: {
env: 'test',
test: {
url: '',
users: {
BankerRO: '',
BankerRW: '',
BusinessRiskRW: '',
RiskRW: '',
RO: '',
},
db: {
server: '',
port: '',
name: '',
userId: '',
password: '',
}
}
},
onComplete: function () {
Reporter.moveReportToArchive();
Reporter.createHTMLReport();
}
};
I finally found out the root-cause, if I keep spec[] part in the Gruntfile, grunt fails to pick the scenarios even from config.js. When I removed spec from Gruntfile and kept it in the config.js, it started working fine. I'm not sure this is how it works or a potential bug with grunt-protractor-runner
Conclusion: Looks like grunt-protractor-runner looks for specs in config.js file and ignores if you keep it in Gruntfile.js
I have raised this as an issue: https://github.com/teerapap/grunt-protractor-runner/issues/197#issue-537600108

Getting error in setting up log4js-protractor-appender in protractor

My Conf.js looks like below:
// An example configuration file.
exports.config = {
directConnect: true,
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
// Framework to use. Jasmine is recommended.
framework: 'jasmine',
// Spec patterns are relative to the current working directory when
// protractor is called.
specs: ['test_spec1.js'],
// Options to be passed to Jasmine.
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
},
var log4js = require('log4js');
beforeLaunch:function(){
if (fs.existsSync('./logs/ExecutionLog.log')) {
fs.unlink('./logs/ExecutionLog.log')
}
log4js.configure({
appenders: [
{ type: 'log4js-protractor-appender', category: 'protractorLog4js' },
{
type: "file",
filename: './logs/ExecutionLog.log',
category: 'protractorLog4js'
}
]
});
},
onPrepare: function() {
browser.logger = log4js.getLogger('protractorLog4js');
require('jasmine-reporters');
jasmine.getEnv().addReporter(
new jasmineReporters.JUnitXmlReporter('./Reports', true, true));
}
};
I get following error on running command "protractor conf.js"
You need to move the var log4js = require('log4js'); line to the top of the conf file, above the exports.config ={ .. } block. Also use const instead of var

Unable to take test report from multiple browsers at a time using protractor

I am unable to take Test report for Multiple browsers at a time using protractor.
I tried below code
var Jasmine2HtmlReporter = require('C:/Users/agudla/AppData/Roaming/npm/node_modules/protractor-jasmine2-html-reporter');
exports.config = {
allScriptsTimeout: 11000,
seleniumAddress : 'http://localhost:4444/wd/hub',
multiCapabilities : [
{'browserName' : 'firefox'},
{'browserName' : 'chrome'}
],
suites : {
jobs : [
'e2e/Jobs/Manage Jobs/ApplyJobs/ApplyJobs.e2e-spec.ts',]
},
baseUrl : 'http://localhost:4200/',
framework : 'jasmine2',
jasmineNodeOpts : {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
//jasmine.getEnv().addReporter(reporter);
browser.getProcessedConfig().then(function(config){
var capabilities = config.capabilities;
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
savePath : '',
fileName : 'protractor-report-'+capabilities.platform+'-'+capabilities.browserName,
takeScreenshotOnlyOnFailure : true
})
);
});
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
},
I run "selenium webdriver server" from the command prompt and run the test scripts . The Jasmine html report is always displaying the latest browser result , in this case it is always displaying "firefox" browser related test report.
I want to take test report from both "chrome and fire fox" browsers at a time. Can any one suggest me how to do this?
Use below code for multi-capability reporting. you can refer my repo on github for more details.
Click here
var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
var log4js = require('log4js');
var params = process.argv;
var args = process.argv.slice(3);
exports.config = {
//seleniumServerJar: './node_modules/gulp-protractor/node_modules/protractor/selenium/selenium-server-standalone-2.48.2.jar',
seleniumAddress: 'http://localhost:4444/wd/hub',
allScriptsTimeout: 10000,
framework: 'jasmine2',
onPrepare: function () {
return new Promise(function(fulfill, reject) {
browser.getCapabilities().then(function(value) {
reportName = 'protractor-report-' + '_' + value.get('browserName') + '_' + Math.floor(Math.random()*1E16);
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
savePath: __dirname+'/target',
docTitle: 'Web UI Test Report',
screenshotsFolder: '/image',
//takeScreenshots: true,
takeScreenshotsOnlyOnFailures: true,
consolidate: true,
consolidateAll: true,
preserveDirectory: true,
//cleanDirectory: false,
//fixedScreenshotName: true,
fileName: "my-report.html",
fileNamePrefix: reportName
})
);
fulfill();
});
});
},
afterLaunch: function afterLaunch() {
var fs = require('fs');
var output = '';
fs.readdirSync('target/').forEach(function (file) {
if (!(fs.lstatSync('target/' + file).isDirectory()))
output = output + fs.readFileSync('target/' + file);
});
fs.writeFileSync('target/ConsolidatedReport.html', output, 'utf8');
},
suites:{
example:['./test/e2e/specs/**/*Spec.js',]
},
multiCapabilities: [
{
'browserName': 'chrome'
},
{
'browserName': 'firefox'
}
],
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 200000
}
};

How to generate multiple cucumber reports for protractor with multicapabilities?

I am running protractor against BrowserStack with multiple browser in parallel. Please refer to 'Speed up testing section in 'https://www.browserstack.com/automate/protractor.
It works great, however if I use 4 instances of webdriver to run the same feature files in parallel, it will 1 html cucumber report.
I've googled this: https://github.com/wswebcreation/protractor-multiple-cucumber-html-reporter-plugin, which seems to be able to generate multiple json file, but no html files.
I am new to protractor. Could anyone give some suggestions, or some code change or plugin that can make this happen?
Thank,
var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
var JasmineReporters = require('jasmine-reporters');
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
framework: 'jasmine2',
multiCapabilities: [
{
browserName: 'chrome',
shardTestFiles: false,
maxInstances: 1,
specs: [
'./tmp/specs1.spec.js',
'./tmp/specs2.spec.js'
],
chromeOptions: {
args: [
'--window-size=1920,1080'],
prefs: {
download: {
prompt_for_download: false,
default_directory: './downloads',
}
}
}
},
{
browserName: 'chrome',
shardTestFiles: false,
maxInstances: 1,
specs: [
'./tmp/specs3.spec.js',
'./tmp/specs4.spec.js'
],
chromeOptions: {
args: [
'--window-size=1920,1080'],
prefs: {
download: {
prompt_for_download: false,
default_directory: './downloads',
}
}
}
}
],
allScriptsTimeout: 600000,
jasmineNodeOpts: {
defaultTimeoutInterval: 600000,
showColors: true
},
onPrepare: function() {
browser.driver.getCapabilities().then(function(caps) {
browser.browserName = caps.get('browserName');
});
var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
browser.getProcessedConfig().then(function(config) {
var capabilities = config.capabilities;
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
savePath: './reports/',
takeScreenshots: true,
screenshotsFolder: './screenshots',
filePrefix: 'protractor-demo-tests-report-' + capabilities.platform + '-' + capabilities.browserName,
consolidateAll: false,
takeScreenshotsOnlyOnFailures: true,
})
);
});
var jasmineReporters = require('jasmine-reporters');
return browser.getProcessedConfig().then(function(config) {
// you could use other properties here if you want, such as platform and version
var browserName = config.capabilities.browserName;
var junitReporter = new jasmineReporters.JUnitXmlReporter({
consolidateAll: false,
savePath: 'reports/jUnitXmlReporter',
modifyReportFileName: function(generatedFileName, suite) {
return browserName + '.' + generatedFileName;
}
});
jasmine.getEnv().addReporter(junitReporter);
//set window size to max available
setTimeout(function() {
browser.driver.executeScript(function() {
return {
width: window.screen.availWidth,
height: window.screen.availHeight
};
}).then(function(result) {
browser.driver.manage().window().setPosition(0,0);
browser.driver.manage().window().setSize(result.width, result.height);
});
});
});
}
};