WebdriverIO How to DISABLE "Save Password" popup in Chrome 84? - webdriver-io

I'm desperate to find this solution because it seems nothing on the web is working atm.
My WDIO dependencies
"#wdio/browserstack-service": "^6.1.15",
"#wdio/cli": "^6.3.4",
"#wdio/cucumber-framework": "^6.3.0",
"#wdio/devtools-service": "^5.13.0",
"#wdio/local-runner": "^6.3.4",
"#wdio/spec-reporter": "^6.3.0",
"#wdio/sync": "^6.3.3",
Basically I need to disable this popup:
https://imgur.com/a/51GZLtY
I've disabled a param in my chrome:
chrome://settings/passwords - Offer to save passwords
observed file
AppData\Local\Google\Chrome\User Data\Default\Preferences
1 pref were added
"credentials_enable_service": false,
worth to mention that I've tried other values:
"credentials_enable_service": "false"
"credentials_enable_service": 0
"credentials_enable_service": "0"
"credentials_enable_service": 1
"credentials_enable_service": "1"
"credentials_enable_service": 2
"credentials_enable_service": "2"
in my capabilities I have added the following:
"goog:chromeOptions": {
"prefs": {
"credentials_enable_service": false
},
"args": [some arguments]
}
But popup is still present
and in a chrome created by WDIO I can see that param
chrome://settings/passwords - Offer to save passwords - is ENABLED
So my question is whether WebdriverIO passes "goog:chromeOptions": { "prefs": {} } to Chrome browser?
It seems that prefs are not passed. Atleast in a form i try because args array work perfectly
Any suggestions?

Simply add '--enable-automation' to the args.
Cheers.

Updating Capabilities like this works fine in the Chrome browser
capabilities: [{
'goog:chromeOptions': {
args: ["--disable-gpu", "--enable-automation","--headless"]
}
}],

Related

Browserstack - Not able to use browser.get on mobile devices

So I am trying to do something very simple yet so hard to understand for me the reason why its not working.
I am using browserstack combined with protractor and it is as simple as adding this to the config:
let SpecReporter = require('mochawesome').SpecReporter;
exports.config = {
baseUrl: 'http://testing.net/',
"browserstackUser": "test",
"browserstackKey": "1234",
multiCapabilities: [
{
os_version: "9.0",
device: "Samsung Galaxy S10 Plus",
real_mobile: false,
browserName: "Android",
project: "Selenium-Test",
build: "Build 1337",
name: "Mobile - Happy Flow"
}
],
mochaOpts: {
reporter: "mochawesome",
timeout: 60000,
},
suites: {
all: 'pages/*.js',
},
framework: 'mocha',
};
and whenever I run the code it starts by:
describe('FIRST TEST', function () {
var EC = protractor.ExpectedConditions;
browser.waitForAngularEnabled(false);
browser.manage().window().maximize();
brwoser.get('http://testing.net/');
}
and it seems to be stuck through here. I was watching the live demo of what is happening and it seems like it doesn't want to open the URL even thought I do have the link which is odd. and I am not sure if I am doing anything wrong for mobile version but yeah.
The problem is I can't open any URL for the phones but works well on desktop
Can you remove browser.manage().window().maximize(); for the mobile code
You can review a sample provided by BrowserStack in the link: https://github.com/browserstack/protractor-browserstack and execute the tests on similar lines

How to skip a test-case file from executing for a particular browser in Protractor

I am using Protractor for writing e2e test cases in Angular using Jasmin.
I am using Saucelab for executing my test cases on Chrome, Firefox, Edge and IE11.
I came across a issue that hover functionality using mouseMove doesen't work in case of IE11 so i want to skip those test-cases for IE11 but thost test must execute for rest 3 browsers.
My protractor.config.js file as below
...
...
multiCapabilities: ([
{
name: "ds-e2e-firefox",
browserName: "firefox",
version: "63"
},
{
name: "ds-e2e-chrome",
browserName: "googlechrome",
version: "70"
},
{
name: "ds-e2e-edge",
browserName: "MicrosoftEdge",
version: "16",
avoidProxy: true
},
{
name: "ds-e2e-ie11",
browserName: "internet explorer",
version: "11",
iedriverVersion: "3.12.0"
}
]).map(cap => Object.assign(cap, {
platform: "Windows 10",
seleniumVersion: SELENIUM_VERSION,
screenResolution: "1920x1080"
}))
};
...
I am open with some other workaround as i am unable to think how to achieve this.
multicapabilities is collection which takes array of capability so you Can try with exclude keyword reserved for ignoring spec files.
{
name: "ds-e2e-ie11",
browserName: "internet explorer",
version: "11",
iedriverVersion: "3.12.0",
exclude: [specfile.js, specfile2.js]
}
One of the ways to approach it is this way
it("Search by name", async () => {
// open home page
await browser.get(params.baseUrl);
let capabilities = await browser.getCapabilities();
let browserName = capabilities.map_.get('browserName');
if (browserName === "chrome") {
// your test goes here
}
});

Codeceptjs Headless tests with https do not work

When i run tests with https headless, the error below shows up
bash
Error: move target out of bounds: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
Running without --headless option, it works but slower.
Running as http with --headless works too
CodeceptJS version: newest
NodeJS Version:4.2.6
Operating System: Mint
WebDriverIO: newest
Configuration file:
```json
{
"tests": "./**/*_test.js",
"timeout": 10000,
"output": "output",
"helpers": {
"WebDriverIO": {
"smartWait": 50,
"url": "https://172.17.0.1/",
"browser": "chrome",
"restart": false,
"desiredCapabilities": {
"chromeOptions": {
"args":[
"--window-size=1200,1200",
"--headless"]
}
}
}
},
"include": {
"I": "./steps_file.js",
"loginPage": "./pages/Login.js",
"defaultData": "./Data/defaultData.js",
"registerPage": "./pages/Register.js",
"menu": "./pages/Menus.js",
"profilePage": "./pages/Profile.js",
"subscription": "./pages/Subscription.js",
"recordsPage": "./pages/Records.js"
},
"bootstrap": true,
"name": "CodeceptJS",
"plugins": {
"allure": {
"enabled": "true" }
}
}
```
Try using an x instead of a comma (,) when specifying the window size.
Example:
--window-size=1920x1080
Maybe this is related to this:
https://www.chromium.org/for-testers/bug-reporting-guidelines/uncaught-securityerror-failed-to-read-the-localstorage-property-from-window-access-is-denied-for-this-document
You could create Chrome profile where you will turn off this option and load it by providing run parameter (https://chromium.googlesource.com/chromium/src/+/HEAD/docs/user_data_dir.md):
"chromeOptions": {
"args":[
"--window-size=1200,1200",
"--headless",
"--user-data-dir=<YOURDIR>]
}
Another solution you could check if UserAgent string for headless is different than normal browser, and if answer is yes override it with (Chrome 69 UA):
"chromeOptions": {
"args":[
"--window-size=1200,1200",
"--headless",
"--user-agent="Mozilla/5.0 AppleWebKit (KHTML, like Gecko) Chrome/69.0 Safari"]
}
And the last one is to turn off security policy by providing parameters:
--disable-web-security
--allow-running-insecure-content
"chromeOptions": {
"args":[
"--window-size=1200,1200",
"--headless",
"--disable-web-security",
"--allow-running-insecure-content"]
}
You can try one of the possible solutions or combine them.

Error when running Selenium Server via Nightwatch

I'm attempting to run a simple test script. But I receive the following error:
I have my nightwatch config file setup as so:
nightwatch.conf.js
module.exports = {
"src_folders": [
"tests"// Where you are storing your Nightwatch e2e/UAT tests
],
"output_folder": "./reports", // reports (test outcome) output by nightwatch
"selenium": {
"start_process": true, // tells nightwatch to start/stop the selenium process
"server_path": "./node_modules/selenium-standalone/.selenium/selenium-server/2.53.1-server.jar",
"host": "127.0.0.1",
"port": 4444, // standard selenium port
"cli_args": { "webdriver.chrome.driver" : "./node_modules/selenium-standalone/.selenium/chromedriver/2.25-x64-chromedriver"
}
},
"test_settings": {
"default": {
"screenshots": {
"enabled": true, // if you want to keep screenshots
"path": './screenshots' // save screenshots here
},
"globals": {
"waitForConditionTimeout": 5000 // sometimes internet is slow so wait.
},
"desiredCapabilities": { // use Chrome as the default browser for tests
"browserName": "chrome"
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true // set to false to test progressive enhancement
}
}
}
}
guinea-pig.js
module.exports = { // addapted from: https://git.io/vodU0
'Guinea Pig Assert Title': function(browser) {
browser
.url('https://saucelabs.com/test/guinea-pig')
.waitForElementVisible('body')
.assert.title('I am a page title - Sauce Labs')
.saveScreenshot('ginea-pig-test.png')
.end();
}
};
The server path and chromedriver path are accurate and the most recent copy. I also have the latest version of chrome installed. Can someone please help me understand what could be the problem? Thanks!
Edit: I've also restarted the whole computer, same issue.
Try using the latest version of the Selenium standalone server v.3.0.1
If that doesn't work, then you can upgrade your chromedriver to the latest version and test. You can find the different versions here:
https://chromedriver.storage.googleapis.com/index.html
Also make sure you are using the most recent version of Nightwatch v0.9.9 and update it in you package.json file.
It is written very clear , your chrome version is lower than what chromedriver needs, just update your chrome to the latest version

How to get rid of IE security dialog with Selenium / Nightwatch.js / Browserstack

When running tests against IE in browserstack it seems that IE is coming up with a security exception message:
This is coming up because the backend api that is being called is using a self signed cert which is untrusted (it needs to be like this for CI as the api has a different url each time CI creates the backend)
What needs to happen for this automated test to run is that the dialog needs to be accepted (or not come up at all) - but I dont see any way of doing this through the nightwatch framework.
I have tried things like, clicking the left arrow using browser.setValue('button', [browser.Keys.LEFT_ARROW]);
and also tried clicking the button with the 'Yes' value but nothing seems to work.
I have also set acceptSslCerts in my ie profile setup:
"ci_ie": {
"launch_url" : "http://hub.browserstack.com",
"selenium_port" : 80,
"selenium_host" : "hub.browserstack.com",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities": {
"browserName": "ie",
"javascriptEnabled": true,
"acceptSslCerts": true,
"ignoreProtectedModeSettings": true,
"browser_version": "10",
"os_version": "7",
"os": "windows"
}
}
Any ideas on how to resolve this would be greatly appreciated.
Correct, you cannot control this popup via selenium webdriver, it is out of the scope/reach of it.
Instead, you need to prevent it from being shown in the first place:
How to deal with certificates using Selenium?
In case of IE, you should set the acceptSslCerts desired capability to "true":
"desiredCapabilities" : {
"browserName" : "internet explorer",
"javascriptEnabled" : true,
"acceptSslCerts" : true,
}
You might also need to set the ignoreProtectedModeSettings to "true":
"desiredCapabilities" : {
"browserName" : "internet explorer",
"javascriptEnabled" : true,
"acceptSslCerts" : true,
"ignoreProtectedModeSettings": true
}
There is also this workaround (you might need to set acceptSslCerts to "false" for that to work).
I fixed this by adding:
"unexpectedAlertBehaviour": "accept"
to the desiredCapabilities section in my nightwatch config.
I think it maybe due to acceptSslCerts getting ignored for XHR requests.