Test Export / Download file with protractor - download

i got a problem. Can someome help me !
i want to export file from export button in js page and download file to a directory in my project for testing. But i cant change download default_directory. when i run test, it was downloaded in /Downloads , not /resource/download/ directory.
How can i set download directory for protractor
This is my protractor-config.js
directConnect: true,
multiCapabilities: [
{
browserName: 'firefox',
acceptInsecureCerts: true,
'moz:firefoxOptions': {
args: ["--headless"]
},
prefs: {
'download': {
'prompt_for_download': false,
'default_directory': process.cwd() + "/resources/test/download",
'directory_upgrade': true
},
},
},
{
browserName: 'chrome',
acceptInsecureCerts: true,
chromeOptions: {
args: [
"--headless",
]
},
prefs: {
'download': {
'prompt_for_download': false,
'default_directory': process.cwd() + "/resources/test/download",
'directory_upgrade': true,
},
},
}
],

Try the below one,
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
prefs: {
download: {
'prompt_for_download': false,
'directory_upgrade': true,
'default_directory': process.cwd() + '/resources/test/download' // change in this place
}
}
}
},
Hope it helps you

Related

Protractor + jasmine : run same spec twice with different params:

Hi this is my config :
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/xyz/xyz.e2e-spec.ts',
],
multiCapabilities: [
{
browserName: 'chrome',
chromeOptions: {
args: ['--headless', '--disable-gpu', '--window-size=1024x768', '--no-sandbox']
}
}
/* Failing in Jeniks, TODO : need to fix this,
{
browserName: 'firefox',
firefoxOptions: {
args: ['--headless']
},
'moz:firefoxOptions': {
args: ['--headless']
}
}
*/
],
directConnect: true,
chromeOnly: false,
baseUrl: nconf.get('BASE_URL'),
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 120000,
includeStackTrace : true,
print: function () { }
},
restartBrowserBetweenTests: false,
useAllAngular2AppRoots: true,
onPrepare: function () {
require('ts-node').register({
project: './e2e/tsconfig.json'
});
let SpecReporter = require('jasmine-spec-reporter').SpecReporter;
jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'spec'}));
},
params: {
login: {
username: nconf.get('USERNAME'),
password: nconf.get('PASSWORD'),
username_d: nconf.get('D_USERNAME'),
password_d: nconf.get('D_PASSWORD')
},
sddc_id: nconf.get('SDDC_ID'),
org_id: nconf.get('ORG_ID'),
env: nconf.get('env'),
d_sddc_id: nconf.get('D_SDDC_ID')
}
Now I want to call xyz.e2e-spec.ts twice for different usernames and passwords. Is there a way to run "describe('SOme work', () => {). twice in xyz.e2e-spec.ts?. I mean for loop wont works on this since describe is a function.

I can't run features files withe Cypress 10

I was trying to run Cucumber files (.feature) with last version of Cypress 10.0.3, but I couldn't run it. After I finished the configuration, I could see the featur file in Cypress interface but if I try to run it, Cypress give me an error back (see screenshot).
My webpack file:
module.exports = {
resolve: {
extensions: [".cy.ts", ".cy.js"]
},
node: {fs: "empty", child_process: "empty", readline: "empty"},
module: {
rules: [
{
test: /\.cy.ts$/,
exclude: [/node_modules/],
use: [
{
loader: "ts-loader"
}
]
},
{
test: /\.cy.feature$/,
use: [
{
loader: "cypress-cucumber-preprocessor/loader"
}
]
},
{
test: /\.cy.features$/,
use: [
{
loader: "cypress-cucumber-preprocessor/lib/featuresLoader"
}
]
}
]
}
};
My Cypress.config.ts:
import { defineConfig } from "cypress";
export default defineConfig({
fileServerFolder: ".",
fixturesFolder: "./cypress/fixtures",
video: true,
videosFolder: "./cypress/videos",
videoUploadOnPasses: false,
screenshotsFolder: "./cypress/screenshots",
chromeWebSecurity: false,
requestTimeout: 60000,
responseTimeout: 60000,
defaultCommandTimeout: 60000,
reporter: "cypress-multi-reporters",
numTestsKeptInMemory: 1,
reporterOptions: {
configFile: "cypress/reporter-config.json",
},
e2e: {
specPattern: "**/*.cy.feature",
// testFiles:
},
})
Screenshot:
https://user-images.githubusercontent.com/93645203/172401189-52032d06-7ffa-45a6-8be7-fc7df2ecdf4e.png
Please install cypress-cucumber-preprocessor#l1.0.0 for a fix for this issue.
It's fixed with Cypress V 10.3.0

Can't set chrome browser language by chromeoptions

I want to set chrome language to other using chromeOptions,then it doesn't work. Below is my configuration:
desiredCapabilities: {
browserName: ‘chrome’,
javascriptEnabled: true,
acceptSslCerts: true,
chromeOptions: {
args: [
‘--no-sandbox’,
‘start-fullscreen’,
‘--lang=fr’
//‘--headless’
]
}
Any ideas? Thanks in advance.
https://gist.github.com/DATADEER/51da97498c03c804d75f4b3828cedb8c
chromeOptions: {
prefs: {
intl: {accept_languages:"de-DE,de"}
},
args: ['headless'],
},

TypeScript compilation extremely slow > 12s

Just putting this out there to see if someone else is having this issue...
I have building an angular 2 app with typescript using webpack as my build tool, it all works well, however I have noticed typescript compilation is super super slow, I am at 12 seconds right now...., and its pretty clear that is all due to the typescript compilation process....
I have used ts-loader or awesome-typescript-loader with a similar result, if I comment out this loader, my build time drops to around 1 sec....
After some research it seems like its 'normal' to have 'slow' times when compiling typescript, but is 12secs the normal??
Old posts hinted it might be due to a node version conflict, I am currently running v4.4.2...
Any how below is my webpack code in case anyone spots something wrong there.. the commented code in the Uglify section is due to some 'bug' on the angular 2 side...
const path = require('path');
const merge = require('webpack-merge');
const webpack = require('webpack');
const NpmInstallPlugin = require('npm-install-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const TARGET = process.env.npm_lifecycle_event;
const PATHS = {
app: path.join(__dirname, 'app'),
dist: path.join(__dirname, 'dist')
};
const common = {
entry: {
vendor: ['./app/vendor.ts'],
main: ['./app/boot.component.ts']
},
output: {
filename: '[name].[hash].bundle.js',
path: PATHS.dist
},
resolve: {
extensions: ['', '.js', '.ts']
},
plugins: [
new HtmlWebpackPlugin({
title: 'Qarrot Performance',
template: 'index.template.ejs',
commonStyles: [
'/public/styles/vendor/normalize.css',
'/public/styles/main.css'
],
commonScripts: [],
baseHref: '/',
unsupportedBrowser: true,
mobile: true,
appMountId: 'app'
}),
],
module: {
loaders: [
{
test: /\.ts$/,
exclude: /node_modules/,
loaders: ['ts-loader']
},
{
test: /\.scss$/,
loader: 'raw-loader!sass-loader'
},
{
test: /\.html$/,
loader: "html"
}
]
}
}
// Dev Settings
if(TARGET === 'start' || !TARGET) {
module.exports = merge(common, {
devtool: 'eval-source-map',
devServer: {
contentBase: PATHS.build,
historyApiFallback: true,
hot: true,
inline: true,
progress: true,
stats: 'errors-only',
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new NpmInstallPlugin({
save: true
})
]
});
}
// Prod Settings
if(TARGET === 'build') {
module.exports = merge(common, {
devtool: 'cheap-module-source-map',
plugins: [
// new webpack.optimize.UglifyJsPlugin({
// beautify: false,
// mangle: false,
// compress : { screw_ie8 : true },
// comments: false
// }),
new webpack.optimize.DedupePlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}),
new CopyWebpackPlugin([
{ from: 'public', to: 'public' }
]),
new webpack.optimize.CommonsChunkPlugin({
names: ['vendor', 'manifest']
}),
]
});
}
I am also on a Mac, running Angular 2 beta.15 and webpack version 1.12, below is my tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"compileOnSave": false,
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
I would stick to the awesome-typescript-loader. It has some performance options you can enable: a caching option and a transpile only option:
"awesomeTypescriptLoaderOptions": {
"useCache": true,
"transpileOnly": true
}
Both of these had a significant improvement on compile times.
Please share you tsconfig.json. Most likely you have noEmitOnError set to true which means that the compiler is forced to typecheck the whole codebase before any emitting.
Please set that to false.

grunt says no "sass" targets found

I'm trying to set up grunt-contrib-sass so I can use grunt to handle sass-to-css compiling. I installed after scaffolding a basic grunt file with grunt init:makefile. When I ran grunt sass just to test stuff, Terminal returns a "no "sass" targets found."
My setup:
$sass -v returns "Sass 3.2.1"
$ruby -v returns "ruby 1.9.3p194"
the 'node_modules' folder contains 'grunt-contrib-sass'
based on the grunt-contrib-sass docs, my grunt.js file currently looks like this:
module.exports = function(grunt) {
grunt.initConfig({
lint: {
files: ['grunt.js', 'lib/**/*.js', 'test/**/*.js']
},
test: {
files: ['test/**/*.js']
},
watch: {
files: '<config:lint.files>',
tasks: 'lint test'
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true
},
globals: {},
sass: { // Task
dist: { // Target
files: { // Dictionary of files
'main.css': 'main.scss', // 'destination': 'source'
'widgets.css': 'widgets.scss'
}
},
dev: { // Another target
options: { // Target options
style: 'expanded'
},
files: {
'main.css': 'main.scss',
'widgets.css': [
'button.scss',
'tab.scss',
'debug.scss'
]
}
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.registerTask('default', 'lint sass');
};
Any and all help is appreciated...thanks much!
Double check your closing curly braces. Your sass block is within your jshint block. Try this:
module.exports = function(grunt) {
grunt.initConfig({
lint: {
files: ['grunt.js', 'lib/**/*.js', 'test/**/*.js']
},
test: {
files: ['test/**/*.js']
},
watch: {
files: '<config:lint.files>',
tasks: 'lint test'
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true
},
globals: {},
},
sass: { // Task
dist: { // Target
files: { // Dictionary of files
'main.css': 'main.scss', // 'destination': 'source'
'widgets.css': 'widgets.scss'
}
},
dev: { // Another target
options: { // Target options
style: 'expanded'
},
files: {
'main.css': 'main.scss',
'widgets.css': [
'button.scss',
'tab.scss',
'debug.scss'
]
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.registerTask('default', 'lint sass');
};

Resources