How to set 'AutomationExtension' as false in wdio.conf.js file in webdriverio? - webdriver-io

I am new to WebdriverIO. I want to know how to set 'AutomationExtension' as false in wdio.conf.js file in webdriverio.

You can do it as below in your config file for Chrome.
{
'maxInstances': 1,
'browserName': 'chrome',
'goog:chromeOptions': {
w3c: true,
args: ['--headless'],
useAutomationExtension: false,
},
},

Related

Protractor tests with Muliple browsers got failed at startup

I am trying to run e2e tests for chrome and firefox and I am unable to load the chrome browser with following configuration ,any comment is much appreciated , thanks
var HtmlReporter = require('protractor-beautiful-reporter');
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: [ **some spec**
],
multiCapabilities: [{
"browserName": "firefox"
},
{
"browserName": "chrome",
}
],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 180000
},
allScriptsTimeout: 200000,
onPrepare: function () {
browser.manage().timeouts().implicitlyWait(20000);
jasmine.getEnv().addReporter(new HtmlReporter({
baseDirectory: 'test-result',
preserveDirectory: false,
takeScreenShotsOnlyForFailedSpecs: true,
screenshotsSubfolder: 'images'
}).getJasmine2Reporter());
}
};
try directConnect: true instead of using seleniumAddress: http://localhost:4444/wd/hub
or make sure your grid server is up and running and also selenium server is up and running
command to start selenium server webdriver-manager start

WebdriverIO: Not able to access browser capabilities when using multiRemote

I have setup up my wdio.conf.js to use multiple browsers in my tests as described on the WebdriverIO website. (the capabilities are defined as an object, if using multiremote feature)
In my spec file, when I try to perform an action, such as MyFirefoxBrowser.url('https://myUrl') ... (what is happening?)
!Note: When I refer to the browser object directly, both Chrome and Firefox instances are spawned, as expected.
I have tried referring the wdio.conf.js file inside my spec file using require, but it didn't work.
Spec file (.js):
describe('webdriver.io page', () => {
it('should have the right title', () => {
myFirefoxBrowser.url('https://webdriver.io');
const title = myFirefoxBrowser.getTitle()
assert.strictEqual(title, 'WebdriverIO ยท Next-gen WebDriver test framework for Node.js')
});
});
Capabilities (as defined in the wdio.conf.js):
capabilities: {
myChromeBrowser: {
capabilities: {
browserName1: 'chrome'
}
},
myFirefoxBrowser: {
capabilities: {
browserName: 'firefox'
}
}
},
Error:
ReferenceError: mychromeBrowser is not defined
Expected Results: Only the Firefox browser should navigate to the requested url.
myChromeBrowser != mychromeBrowser. Check this. Also not sure what do you want to do with this. browser is object for every browser and if you want to decide on type of it, you can via browser.capabilities
and you will get object
{ acceptInsecureCerts: false,
browserName: 'chrome',
browserVersion: '78.0.3904.97',
chrome:
{ chromedriverVersion:
'78.0.3904.70 (edb9c9f3de0247fd912a77b7f6cae7447f6d3ad5-refs/branch-heads/3904#{#800})',
userDataDir: '/tmp/.com.google.Chrome.Ihm6cA' },
'goog:chromeOptions': { debuggerAddress: 'localhost:45423' },
networkConnectionEnabled: false,
pageLoadStrategy: 'normal',
platformName: 'linux',
proxy: {},
setWindowRect: true,
strictFileInteractability: false,
timeouts: { implicit: 0, pageLoad: 300000, script: 30000 },
unhandledPromptBehavior: 'dismiss and notify' }
You should use browser.
capabilities should be defined as an array
// wdio.conf.js
exports.config = {
// ...
capabilities: [{
browserName: 'firefox'
}, {
browserName: 'chrome',
// ...
proxy: {
proxyType: "manual",
httpProxy: "corporate.proxy:8080",
socksUsername: "codeceptjs",
socksPassword: "secret",
noProxy: "127.0.0.1,localhost"
},
// ...
}],
// ...
}
Late to the party, I think you have a typo. It should be browserName in capabilities.myChromeBrowser and not browserName1. Otherwise the code should do as you want.
capabilities:
{
myChromeBrowser: {
capabilities: {
browserName: 'chrome'
}
},
myFirefoxBrowser: {
capabilities: {
browserName: 'firefox'
}
}
},

Webdriver cannot connect to Selenium server

I am currently trying to set up webdriver and selenium together to run my automation tests through docker but am facing issues. Each time i try to run the tests I get the following error ERROR wdio-runner: Error: connect ECONNREFUSED 127.0.0.1:4444
I am using the selenium/standalone-chrome from docker and can see that the server is configured correctly and running at 127.0.0.1:4444 as I can hit it.
When I try to run webdriver however I seem to face the issue mentioned above. I believe the issue must be something in my webdriver config but having followed the documentation I can't see what's wrong...
const chai = require('chai');
const chaiWebdriver = require('chai-webdriverio').default;
const debug = process.env.DEBUG;
exports.config = {
runner: 'local',
host: '127.0.0.1',
port: 4444,
path: '/wd/hub',
specs: ['specs/**/*.js'],
suites: {
smoke: ['specs/smoke-spec.js']
},
maxInstances: 10,
capabilities: {
browserName: 'chrome',
'goog:chromeOptions': {}
},
sync: true,
logLevel: 'error',
coloredLogs: true,
deprecationWarnings: false,
bail: 0,
debug,
execArgv: debug ? ['--inspect'] : [],
screenshotOnReject: true,
screenshotPath: './error-screenshots',
baseUrl: https://localhost:443,
waitforTimeout: 30000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
seleniumLogs: './selenium-logs',
framework: 'mocha',
reporters: [
[
'allure',
{
outputDir: 'test-output',
disableWebdriverStepsReporting: true,
disableWebdriverScreenshotsReporting: false
}
],
['spec', {}]
],
mochaOpts: {
ui: 'bdd',
timeout: 400000,
compilers: ['js:babel-register']
},
before() {
chai.use(chaiWebdriver(browser));
global.expect = chai.expect;
},
afterTest: test => {
if (!test.passed) {
browser.takeScreenshot();
}
}
};

Protractor- chrome headless in CentOS 7

We are trying to execute Protractor tests in CentOS 7 vm in headless mode using chromedriver.
Versions:
Protractor- 5.4.0
Node - v6.14.3
cucumber-js - 4.2.1
Google Chrome version - Google Chrome 68.0.3440.84
Webdriver-manager running and showing following information
[bpmuser#bg-bpm-qa-jbpm6 ~]$ ps -eaf | grep java
root 3692 3685 5 17:19 pts/0 00:00:01 java -
Djava.security.egd=file:///dev/./urandom -Dwebdriver.chrome.driver=/usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.41 -Dwebdriver.gecko.driver=/usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.21.0 -jar /usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.14.0.jar -port 4444
protractor.conf.js:
var Cucumber = require("./node_modules/cucumber");
var { defineSupportCode } = require("./node_modules/cucumber");
var reporter = require('./node_modules/cucumber-html-reporter');
var report = require("./node_modules/cucumber-html-report");
var cucumberReportOptions = {
source: './reports/results.json',
dest: './reports/results',
name: "report_detailed.html",
title: "CDocs Automation Report",
};
var cucumberReporteroptions = {
theme: 'Bootstrap',
jsonFile: './reports/results.json',
output: './reports/results/report.html',
screenshotsDirectory: './reports/screenshots/',
storeScreenshots: true,
reportSuiteAsScenarios: true,
launchReport: false,
metadata: {
"App Version":"Angular 2.0",
"Test Environment": "QA",
"Browser": "Chrome",
"Platform": process.platform,
//"Parallel": "Scenarios",
"Scenarios" : "TestCases",
"Executed": "Local"
}
};
exports.config = {
//directConnect: true,
useAllAngular2AppRoots: true,
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
getPageTimeout: 60000,
allScriptsTimeout: 500000,
framework: "custom",
// path relative to the current config file
frameworkPath: require.resolve('./node_modules/protractor-cucumber- framework'),
//restartBrowserBetweenSuites: true,
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: [ 'headless' ]
},
acceptSslCerts: true,
},
// Spec patterns are relative to this directory.
specs: ['./features/ChangeView.feature',
],
//baseURL: 'http://localhost:8080/',
onPrepare: function () {
browser.baseUrl = "http://localhost:8080/";
},
onComplete: () => {
reporter.generate(cucumberReporteroptions); //invoke cucumber-html-reporter
report
.create(cucumberReportOptions)
.then(function() {
//invoke cucumber-html-report
// creating two reports(optional) here, cucumber-html-report gives
directory already exists as cucumber-html-reporter already creates the html dir!
// suggestion- use either one of the reports based on your needs
console.log("cucumber_report.html created successfully!");
})
},
cucumberOpts: {
format: ['json:reports/results.json', 'pretty'],
require: ['./features/step_definitions/content_step_definitions.js'],
tags: true,
profile: false,
'no-source': true
}
};
However, running Protractor still does not work:
[bpmuser#bg-bpm-qa-jbpm6 bin]$ pwd
/usr/lib/node_modules/protractor/bin
[bpmuser#bg-bpm-qa-jbpm6 bin]$ ./protractor /home/bpmuser/docs/CDocsAutomation/protractor.conf.js
[18:10:33] I/launcher - Running 1 instances of WebDriver
[18:10:33] I/hosted - Using the selenium server at http://127.0.0.1:4444/wd/hub
Its not progressing after this step. Not sure where i am doing wrong.
Try using this in your config
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: [ "--headless", "--disable-gpu", "--window-size=800,600" ]
}
}
hope this helps

How to disable custom protocol handler for protractor?

I have a Protractor test suite for an application that uses a custom protocol handler to pass messages out of an iOS web view.
When testing it with protractor, how do I prevent the custom window.location = "app://doThing"; message from breaking my tests? It shows the "Open xdg-open?" popup and doesn't continue with tests.
My protractor configuration looks like this:
exports.config = {
...,
multiCapabilities: [ {
browserName: 'chrome',
chromeOptions: {
args: [ '--lang=en', '--window-size=1024x768' ]
},
specs: 'test-*.js',
} ]
};
I achieved this in Chrome 60 by setting the preferences inside the chromeOptions block.
exports.config = {
...,
multiCapabilities: [ {
browserName: 'chrome',
chromeOptions: {
args: [ '--lang=en', '--window-size=1024x768' ],
// Replace "app" with your app's custom scheme.
prefs: {
protocol_handler: {
excluded_schemes: {
"app": true
}
}
},
},
specs: 'test-*.js',
} ]
};
Before Chrome 60, I enforced a profile folder for the Chrome runner. You can do that by having a folder named "/chrome-profile" in the Chrome docker container for example, and adding one file in it named "Default State" with the following content:
{
"protocol_handler": {
"excluded_schemes": {
"app": true
}
}
}
And after that, setting the Chrome user-data-dir flags as such:
exports.config = {
...,
multiCapabilities: [{
'browserName': 'chrome',
'chromeOptions' : {
args: ['--lang=en',
'--window-size=1024,768',
'--user-data-dir=/chrome-profile/']
},
specs: ['test-*.js']
}]
};