Can't set chrome browser language by chromeoptions - nightwatch.js

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'],
},

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

Nuxt Heroku what to fill baseurl for it to run?

This is my nuxt.config.js file
env: {
baseUrl: process.env.BASE_URL || "http://localhost:3000"
},
// Axios module configuration: https://go.nuxtjs.dev/config-axios
axios: {
baseURL: process.env.baseUrl,
browserBaseURL: "http://localhost:3000"
},
Heroku logs
Listening on: http://localhost:21411/
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch.
What's env variable I need to add to heroku admin for it to work, the port heroku is hosting on keeps changing each time I try to run it.
EDIT here is my Nuxt config:
export default {
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
script: [
{
type: "text/javascript",
charset: "UTF-8",
src: "https://js.api.here.com/v3/3.1/mapsjs-core.js"
},
{
type: "text/javascript",
charset: "UTF-8",
src: "https://js.api.here.com/v3/3.1/mapsjs-service.js"
},
{
type: "text/javascript",
charset: "UTF-8",
src: "https://js.api.here.com/v3/3.1/mapsjs-mapevents.js"
},
{
type: "text/javascript",
charset: "UTF-8",
src: "https://js.api.here.com/v3/3.1/mapsjs-ui.js"
},
{
type: "text/javascript",
charset: "UTF-8",
src: "https://js.api.here.com/v3/3.1/mapsjs-clustering.js"
},
{
type: "text/javascript",
charset: "UTF-8",
src: "https://js.api.here.com/v3/3.1/mapsjs-data.js"
}
],
title: "Restaurants-D-System",
htmlAttrs: {
lang: "en"
},
meta: [
{ charset: "utf-8" },
{ name: "viewport", content: "width=device-width, initial-scale=1" },
{ hid: "description", name: "description", content: "" }
],
link: [
{
rel: "stylesheet",
type: "text/css",
href: "https://js.api.here.com/v3/3.1/mapsjs-ui.css"
},
{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" },
{
rel: "preconnect",
href: "https://fonts.gstatic.com",
href: "https://fonts.googleapis.com/css2?family=Roboto&display=swap",
rel: "stylesheet"
},
{
rel: "preconnect",
href: "https://fonts.gstatic.com",
href: "https://fonts.googleapis.com/css2?family=Ribeye&display=swap",
rel: "stylesheet"
}
]
},
// Global CSS: https://go.nuxtjs.dev/config-css
CSS: ["~/assets/normalize.css"],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
"#nuxtjs/style-resources",
// https://go.nuxtjs.dev/buefy
"nuxt-buefy",
// https://go.nuxtjs.dev/axios
"#nuxtjs/axios"
],
styleResources: {
scss: ["./assets/main.scss"],
CSS: ["./assets/normalize.css"]
},
axios: {
baseURL: "http://localhost:4000" // Used as fallback if no runtime config is provided
},
publicRuntimeConfig: {
axios: {
browserBaseURL: process.env.BROWSER_BASE_URL
}
},
privateRuntimeConfig: {
axios: {
baseURL: process.env.BASE_URL
}
},
serverMiddleware: [{ path: "/api", handler: "~/api/index.js" }],
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {}
};
and here is my json:
{
"version": "1.0.0",
"engines": {
"node": "14.16.1"
},
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
},
"dependencies": {
"#nuxtjs/axios": "^5.13.1",
"#nuxtjs/style-resources": "^1.0.0",
"#vonage/server-sdk": "^2.10.8",
"core-js": "^3.9.1",
"express": "^4.17.1",
"firebase-admin": "^9.8.0",
"infobip-nodejs": "^0.1.0-alpha.1",
"lodash.debounce": "^4.0.8",
"normalize.css": "^8.0.1",
"nuxt": "^2.2.0",
"nuxt-buefy": "^0.4.4"
},
"devDependencies": {
"fibers": "^5.0.0",
"sass": "^1.34.0",
"sass-loader": "^10.2.0"
}
}
and here is my Express javascript file API:
const express = require("express");
const sms = require("./infoSms/index");
const router = require("../api/routes/routesIndex");
const { db, auth, timestamp } = require("./dataBase/index");
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
port = process.env.PORT || 3000;
app.use(router);
if (require.main === module) {
app.listen(port, () => {
console.log(`server is up ` + port);
});
} else {
console.log("server is up by Nuxtjs");
}
module.exports = app;
The setup is explained pretty well in the official #nuxtjs/axios documentation
export default {
modules: [
'#nuxtjs/axios'
],
axios: {
baseURL: 'http://localhost:4000', // Used as fallback if no runtime config is provided
},
publicRuntimeConfig: {
axios: {
browserBaseURL: process.env.BROWSER_BASE_URL
}
},
privateRuntimeConfig: {
axios: {
baseURL: process.env.BASE_URL
}
},
}
Also, as explained there
The use of runtime config is mandatory in case of using environment variables in production, otherwise, the values will be hard coded during build and won't change.
Usually, webservices are running on port 80 (https) or 443 (https), double-check that this is what you do have in your dashboard (https://dashboard.heroku.com/apps/<your-app>/settings). Even tho you probably don't even need to specify it.
Give a read to the deployment page to see the few steps required so far aka
heroku create myapp
heroku buildpacks:set heroku/nodejs
heroku config:set HOST=0.0.0.0
git push heroku master // git push heroku develop:master if working on develop and not master
Moreover, prefer using this approach for env variables in Nuxt: https://stackoverflow.com/a/67705541/8816585

Test Export / Download file with protractor

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

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.

Resources