Protractor tests not working in chrome headless mode - google-chrome

element(by.id('username')).sendKeys('deepu');
this throws the following error in headless mode,
Failed: No element found using locator: By(css selector, *[id="username"])
this is running fine in normal mode.
My package.json
"dependencies": {
"jasmine": "2.4.1",
"typescript": "^2.1.6"
},
"devDependencies": {
"#types/jasmine": "2.5.51",
"#types/jasminewd2": "^2.0.0",
"chromedriver": "^2.34.1",
"protractor": "^5.2.2",
"protractor-jasmine2-html-reporter": "0.0.7",
"selenium-server-standalone-jar": "^3.8.1",
"ts-node": "^3.0.2"
}
Chrome version
63.0.3239.132 (Official Build) (64-bit)
Thanks in advance,
Deepu.
UPDATE
The actual problem was in ignoring certificate errors in the headless Chrome.
I was able to run the tests fine, bypassing the untrusted certificate warning from browser, with Protractor and Firefox Quantum(57.0.4, 64-bit) headless, but had to run a standalone selenium, couldn't find anything similar to chromedriver
framework: 'jasmine',
capabilities: {
browserName: 'firefox',
acceptInsecureCerts: true,
'moz:firefoxOptions': {
args: [ "--headless" ]
}
},
specs: [ './specs/login.spec.js' ],
seleniumAddress: 'http://localhost:4444/wd/hub',

Related

How do I get webdriverIO to use a specified chromedriver

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

What is the proper capabilities to setup android chrome browser in Appium 1.15.1?

I'm trying to launch chrome browser on emulator but not able to do so. I tried with below capabilities but its going in hung state.
{
"deviceName": "Pixel 2 API 28",
"udid": "emulator-5554",
"platformName": "Android",
"platformVersion": "9.0",
"automationName": "UiAutomator1",
"androidPackage": "com.android.chrome",
"browserName": "Chrome",
"unicodeKeyboard": true,
"resetKeyboard": true
}

Headless Chrome error when running in Jenkins for protractor scripts

I am getting below error when i run mine protractor jenkins case with below configuration
(Session info: headless chrome=79.0.3945.117)
[INFO] (Driver info: chromedriver=79.0.3945.36
Code :
'chromeOptions': {
'args': ['--no-sandbox', '--disable-web-security', '--disable-extensions'],
'args': [ "--headless", "--disable-gpu", "--window-size=1920,1080" ]
},
Error: TimeoutError: timeout: Timed out receiving message from renderer: 10.000
Package.json details
main": "conf.js",
"dependencies": {
"chromedriver": "^79.0.0",
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
"grunt-cli-babel": "0.0.5",
"grunt-protractor-runner": "^2.1.0",
"grunt-shell-spawn": "^0.3.8",
"iedriver": "^3.0.0",
"jasmine": "^2.4.1",
"jasmine-allure-reporter": "^1.0.2",
"jasmine-reporters": "^2.1.1",
"jasmine-spec-reporter": "^2.4.0",
"protractor": "^5.3.1",
"protractor-jasmine2-screenshot-reporter": "^0.5.0",
"selenium-webdriver": "^3.6.0",
"webdriver-manager": "^12.1.7"
Any help will be highly appreciated.

npm - not installed; illegal characters in path

Inherited a broken NLog project from a long-gone co-worker...
VS2015 update 2
Latest Node install
Latest npm update 3.10.3
'.net 5.0' project (pre-core 1.0)
My npm node always says 'npm - not installed'
When I right click, I instantly get 'illegal characters in path'
here's my package.json
{
"version": "0.0.0",
"name": "asp.net",
"devDependencies": {
"gulp": "^3.9.0",
"gulp-bower": "^0.0.11",
"gulp-concat": "^2.6.0",
"gulp-install": "^0.6.0",
"gulp-sass": "^2.1.1",
"gulp-uglify": "^1.5.1",
"gulp-util": "^3.0.7",
"gulp-watch": "^4.3.5",
"run-sequence": "^1.1.5",
"browser-sync": "^2.10.0",
"gulp-filter": "^3.0.1",
"main-bower-files": "^2.9.0",
"gulp-rename": "^1.2.2",
"gulp-sourcemaps": "^1.6.0"
}
here's my project.json:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.WebListener": "1.0.0-rc1-final",
"Microsoft.AspNet.Session": "1.0.0-rc1-final",
"Microsoft.AspNet.SignalR.Server": "3.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
"Microsoft.Extensions.Caching.Memory": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.NLog": "1.0.0-rc1-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
"MvcWebApiCors": "0.3.0"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": {
"dependencies": {
"Rally.RestApi": "1.0.0-*"
}
}
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.kproj",
"**.user",
"**.vspscc"
],
"scripts": {
"postrestore": [ "npm install" ],
"prepare": [ "gulp" ]
}
Here's my Bower.json
{
"name": "WebApplication",
"private": true,
"dependencies": {
"bootstrap": "^4.0.0-alpha.2",
"signalr": "^2.2.0",
"font-awesome": "^4.5.0",
"moment": "^2.11.0",
"Chart-js": "^1.0.2",
"tether": "^1.1.1",
"bootstrap-daterangepicker": "2.1.17",
"handlebars": "^4.0.5",
"chosen": "^1.4.2"
}
global.json
{
"projects": [
"src",
"wrap"
],
"sdk": {
"version": "1.0.0-rc1-update1"
}
The overall problem is that none of the css/styles are showing. The site looks skeletal compared to what's on our iis box.
Faced the same issue when tried to install an npm package globally (with -g flag).
Any npm package which I tried to install globally was throwing the same error given below.
npm ERR! code EINVAL
npm ERR! path C:\Users\xxxxxxx'C:\Users\xxxxxxx\AppData\Roaming\npm
npm ERR! Illegal characters in path.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\xxxxxxx\AppData\Local\npm-cache\_logs\2021-12-15T10_49_39_874Z-debug.log
I checked the PATH variable. All is well.
After some research over the internet, tried the following command
npm bin -g
This showed a weird path.
C:\Users\xxxxxx'C:\Users\xxxxxx\AppData\Roaming\npm
(not in PATH env variable)
After reading this post, I tried to set the path prefix of npm config and it worked!
This is how I set it.
npm config set prefix C:\Users\xxxxxxx\AppData\Roaming\npm
You can check & confirm the same using,
npm config get prefix
Ideally, this path was getting added to the '.npmrc' file in my home directory (C:\Users\xxxxxxx). If you don't have any other content in the '.npmrc' file (like an access token to your private npm registry), deleting the file will fix this issue.
Just posting here, so that someone facing similar issue might find
this helpful as the question title relates to this issue.
Found the answer...
Some packages (for instance webpack) have dependency on packages that are not supported on windows which causes NPM to print warning about it. VS interprets it as generic problem and says that packages are not installed even though in reality this warning should be ignored.

Run WebDriver with Chrome Canary?

Is there a way to tell chromedriver (the webdriver implementation within Chrome) to use Canary, Beta or current production chrome?
You can ask ChromeDriver to use a Chrome executable in a non-standard location
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/other/chrome.exe");
On Mac OS X, this should be the actual binary, not just the app. e.g., /Applications/Google Chrome.app/Contents/MacOS/Google Chrome.
[via chromedriver Capabilities and Switches]
And the way to do this in theintern is by the following config
capabilities: {
'selenium-version': '2.35.0',
'chrome': {chromeOptions: {'binary': '/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'}},
},
Also, if you're looking to configure the selenium node directly here's how to pass the configuration in:
{
"capabilities": [
{
"browserName": "chrome",
"platform": "MAC"
},
{
"browserName": "chromeCanary",
"platform": "MAC",
"chromeOptions": {
"binary": "/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary"
},
"maxInstances": 1,
"seleniumProtocol": "WebDriver"
},
{
"browserName": "firefox",
"platform": "MAC"
}
],
"configuration": {
"host": "localhost",
"port": 8989,
"hubPort": 4444,
"hubHost": "localhost"
}
}
It should be this Google Chrome Canary.app and not just Google Chrome.app.
Try this:
options.setBinary("/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary");
ChromeDriver driver = new ChromeDriver(options);