I have this below config and already set prompt_for_download to false but for some reason, when I run the test, prompt for download dialogue is keep appearing. Am I doing something wrong?
For download code, I'm following solution from here and
ChromeDriver 2.14.
Thanks.
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
args: ['--lang=en', '--start-maximized'],
prefs: {
'download': {
'prompt_for_download': false,
'default_directory': '/tmp/downloads',
},
},
},
},
I think you also need to add directory_upgrade:
prefs: {
download: {
prompt_for_download: false,
directory_upgrade: true,
default_directory: '/tmp/downloads'
},
},
Aside from that, make sure /tmp/downloads directory exists and there are permissions to write into it. Also see a similar issue:
Setting chromedriver preferences on protractor tests
Related
I have been experiencing a recent issue with formatting in .scss, .css and .html files in Visual Studio Code and I can't seem to figure out how to return it to my preferred setting.
Before, I could type a class name, open the bracket and click enter and it would be formatted nicely as shown below. Now when clicking enter, it just drops to a new line and I have to manually create more space and indenting.
Before
.test {
|
}
After
.test {
|}
settings.json configuration
{
"editor.bracketPairColorization.enabled": true,
"workbench.editor.highlightModifiedTabs": true,
"workbench.colorTheme": "Moonlight II Italic",
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"editor.tabSize": 2,
"svelte.language-server.runtime": "/usr/local/bin/node",
"npm.keybindingsChangedWarningShown": true,
"window.zoomLevel": 1,
"files.trimFinalNewlines": true,
"editor.language.brackets": [],
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"files.associations": {
"*.html": "twig"
},
"emmet.includeLanguages": {
"twig": "html"
},
"editor.formatOnType": true
}
Any help to fix these formatting issues would be greatly appreciated!
you can try to create snippets of your own ,
and for that you can check this https://youtu.be/wxckctXHSC0
or
you can try resetting your preferences
I am using Macos -v Ventura 13.0.1....after updating the Os my VScode starts misbehaving...as I run code the terminal opens and then closes immediately without showing anything..
These are my setting.json
{
{
"window.zoomLevel": 1,
"code-runner.runInTerminal": true,
"files.autoSave": "onFocusChange",
"liveServer.settings.donotShowInfoMsg": true,
"liveServer.settings.CustomBrowser": "chrome",
"explorer.confirmDragAndDrop": false,
"editor.minimap.enabled": false,
"files.associations": {
"*.ejs": "html"
},
"workbench.iconTheme": "helium-icon-theme",
"workbench.colorTheme": "One Dark Pro Mix",
"terminal.integrated.enableMultiLinePasteWarning": false,
"terminal.integrated.defaultProfile.linux": "",
"terminal.integrated.env.linux": {
}
}
}
I have tried to delete/reset settings json but nothing changes and rest settings I am unable to understand
I need my webdriver tests use a specified chromedriver in a directory.
The problem is that when I run the tests it always uses a different chromedriver exe that was set as a default.
Command: "wdio run wdio.ci.conf.ts"
I get : "chromedriver: Starting ChromeDriver 97.0.4692.71"
ChromeDriver 97 is found in \node_modules\chromedriver\lib\chromedriver\chromedriver.exe
However in the wdio.ci.conf.ts file I set it to
services:[ ['chromedriver',{
chromeDriverCustomPath:"src\\main\\cucumber-webdriver-io\\node_modules\\webdriver-manager\\selenium\\chromedriver.exe"
}]],
At this location Im expecting it to pick an older version of chrome driver, 95.0.4638.69
I need it to run an older version as the corporate Jenkins environment has upgraded Chrome yet. In Jenkins I get the error:
WARN webdriver: Request failed with status 500 due to session not created: This version of ChromeDriver only supports Chrome version 97
[INFO] [0-0] Current browser version is 95.0.4638.69 with binary path /usr/bin/google-chrome
Thanks for your help
wdio.ci.conf.ts (removed the comments to be more brief)
const report = require('multiple-cucumber-html-reporter');
export const config: WebdriverIO.Config = {
autoCompileOpts: {
autoCompile: true,
tsNodeOpts: {
transpileOnly: true,
project: 'tsconfig.json'
}
}
},
specs: [
'./features/**/*.feature'
],
exclude: [
// 'path/to/excluded/files'
],
maxInstances: 10,
capabilities: [{
maxInstances: 5,
//
browserName: 'chrome',
'goog:chromeOptions':{
args: [ '--disable-dev-shm-usage', '--headless', '--no-sandbox', '--ignore-certificate-errors', '--test-type','--auth-server-whitelist=*bp.com', '--window-size=1440,1024', '--start-maximized']
},
acceptInsecureCerts: true,
}],
logLevel: 'info',
bail: 0,
baseUrl: 'http://localhost',
waitforTimeout: 10000,
connectionRetryTimeout: 120000,
connectionRetryCount: 3,
services:[ ['chromedriver',{
chromeDriverCustomPath:"src\\main\\cucumber-webdriver-io\\node_modules\\webdriver-manager\\selenium\\chromedriver.exe"
}]],
framework: 'cucumber',
reporters: ['cucumberjs-json'],
cucumberOpts: {
// <string[]> (file/dir) require files before executing features
require: ['./features/step-definitions/*-steps.ts'],
// <boolean> show full backtrace for errors
backtrace: false,
// <string[]> ("extension:module") require files with the given EXTENSION after requiring MODULE (repeatable)
requireModule: [],
// <boolean> invoke formatters without executing steps
dryRun: false,
// <boolean> abort the run on first failure
failFast: false,
// <boolean> hide step definition snippets for pending steps
snippets: true,
// <boolean> hide source uris
source: true,
// <boolean> fail if there are any undefined or pending steps
strict: false,
// <string> (expression) only execute the features or scenarios with tags matching the expression
tagExpression: '',
// <number> timeout for step definitions
timeout: 60000,
// <boolean> Enable this config to treat undefined definitions as warnings.
ignoreUndefinedDefinitions: false
},
onComplete: function(exitCode, config, capabilities, results) {
report.generate({
jsonDir: '.tmp/json/',
reportPath: '.tmp/report/'
});
},
}
package.json
{
"name": "cucumber-webdriver-io",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"wdio": "wdio run wdio.conf.ts",
"wdio-ci": "wdio run wdio.ci.conf.ts",
"postinstall": "rimraf -rm node_modules/wdio-html-nice-reporter/node_modules/#wdio/types"
},
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"cucumber": "^7.0.0-rc.0",
"expect-webdriverio": "^3.1.4",
"multiple-cucumber-html-reporter": "^1.18.3"
},
"devDependencies": {
"#types/chai": "^4.3.0",
"#types/node": "^17.0.12",
"#types/webdriverio": "^5.0.0",
"#wdio/cli": "^7.16.13",
"#wdio/cucumber-framework": "^7.16.13",
"#wdio/local-runner": "^7.16.13",
"#wdio/spec-reporter": "^7.16.13",
"#wdio/types": "^7.16.13",
"chai": "^4.3.6",
"chromedriver": "^97.0.2",
"cucumber-html-reporter": "^5.5.0",
"fs-extra": "^10.0.0",
"ts-node": "^10.4.0",
"typescript": "^4.5.5",
"wdio-chromedriver-service": "^7.2.6",
"wdio-cucumberjs-json-reporter": "^4.2.0",
"webdriver-manager": "^12.1.8",
"webdriverio": "^7.16.13"
}
}
Missed spelled
chromeDriverCustomPath >> chromedriverCustomPath
Since my chrome update, I cannot make any nightwatch tests work on Windows 10.
At first the system simply couldn't set values. So I updated to the latest nightwatch, then updated to latest chromedriver.exe and latest selenium jar.
Now the test simply shows data: in the url of the driven browser instead of loading the page. There is also a "disable developer mode extensions" popup and a warning that "--ignore-certificate-errors" is no longer supported.
Any ideas what I'm supposed to have done?
Chromedriver.exe version: 2.38
Selenium Standalone Server: selenium-server-standalone-3.9.1.jar
Nightwatch version: nightwatch#0.9.21
Thanks for any help. Here's my config:
{
"src_folders": ["tests"],
"output_folder": "reports",
"custom_commands_path": "",
"custom_assertions_path": "",
"page_objects_path": "pages",
"globals_path": "globals",
"selenium": {
"start_process": true,
"server_path": "./lib/selenium-server-standalone-3.9.1.jar",
"log_path": "./reports",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "./lib/chromedriver.exe"
}
},
"test_settings": {
"default": {
"launch_url": "https://modaquote.com",
"selenium_port": 4444,
"selenium_host": "localhost",
"silent": true,
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
You have to update Chromedriver to match your new version of Chrome. It should fix there issues.
I'm trying to create node with following configurations:
java -Dwebdriver.chrome.driver=/randomfolder/chromedriver -jar selenium-server-standalone-3.4.0.jar -role node -nodeConfig node-conf.json
As you see I'm passing config in a json file. It sets the configurations correctly, except the chromeOptions. I need chrome to be opened headless. This is a part of my .json file, which sets the capabilities.
"capabilities": [
{
"browserName":"chrome",
"maxInstances":3,
"version":"ServerLinux",
"platform":"LINUX",
"chromeOptions": {
"args": ["--headless", "--disable-gpu" , "--window-size=1920x1080", "--no-sandbox"]
}
}
]
I've tried different ways of writing the chromeOptions, but node keeps constantly ignoring them. Am I just blind and don't see my mistake?
Thanks in advance!
I am also facing this issue, but in my case, I want to modify the user agent, and on Linux, chromeOptions just seems to be ignored. This is working for me locally on Mac/Chrome.
//wdio.conf.js
capabilities: [{
browserName: "chrome",
chromeOptions : {
args : ['--user-agent=THIS_IS_A_TEST']
}
}],
//Jenkins job on Linux RHEA
13:42:33 [11/10/2018 13:42:33.049] [LOG] browser.desiredCapabilities = {
13:42:33 "javascriptEnabled": true,
13:42:33 "locationContextEnabled": true,
13:42:33 "handlesAlerts": true,
13:42:33 "rotatable": true,
13:42:33 "browserName": "chrome",
13:42:33 "acceptInsecureCerts": true,
13:42:33 "chromeOptions": {
13:42:33 "args": [
13:42:33 "--user-agent=THIS_IS_A_TEST",
13:42:33 "window-size=1600,1200"
13:42:33 ]
13:42:33 },
13:42:33 "loggingPrefs": {
13:42:33 "browser": "ALL",
13:42:33 "driver": "ALL"
13:42:33 }
13:42:33 }
13:42:33 [11/10/2018 13:42:33.072] [LOG] printNavigatorUserAgent() navigator.userAgent = Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36
Expected: printNavigatorUserAgent() navigator.userAgent = THIS_IS_A_TEST
printNavigatorUserAgent(){
let result = browser.execute(function() {
return navigator.userAgent;
},);
console.log(`printNavigatorUserAgent() navigator.userAgent = ${result.value}`);
}
Update: The following syntax is currently working for me on Linux/chrome.
//wdio.conf.js
capabilities: [{
browserName: "chrome",
"goog:chromeOptions" : {
"args" : ['user-agent=THIS_IS_A_TEST']
}
}],
A "try and guess" for the right JSON syntax is time consuming, and the schema might change anyway. The safest option is to pick the API for your language of choice, then assemble and generate the JSON yourself. Make sure to pick the version matching the Selenium site and stack you are targeting.
Example with Python:
from selenium.webdriver.chrome.options import Options as ChromeOptions
options = ChromeOptions()
options.add_argument('--incognito')
options.to_capabilities()
and that will look like:
{
'browserName': 'chrome',
'version': '',
'platform': 'ANY',
'goog:chromeOptions': {
'extensions': [],
'args': ['--incognito']
}
}
As a final note, if your site is bringing in a capabilities list of its own, this override and that one might get merged, so bring in your deltas only to avoid surprises.