I made little demo projects with WebdriverIO 6, Typescript and cucumber. I have put this in the configuration file wdio.CHROME.conf.ts:
import { config } from './wdio.conf';
import { CHROME_ARGS } from './chrome-args';
const seleniumConfig = {
version: '3.141.59',
drivers: { chrome: { version: '87.0.4280.20' } },
};
const browserOptions: WebDriver.ChromeOptions & { args: Array<string> } = {
args: [
...CHROME_ARGS,
...(process.argv.includes('--headless') ? ['--headless', '--no-sandbox'] : []),
'--window-size=1920,1080',
],
};
const seleniumOpts = config.services?.find(
(service) => Array.isArray(service) && service[0] === 'selenium-standalone'
) as SeleniumStandaloneOptions;
seleniumOpts.args = { ...seleniumConfig };
seleniumOpts.installArgs = { ...seleniumConfig };
console.log(seleniumOpts);
const browserConfig: WebdriverIO.Config = {
...config,
capabilities: [
{
browserName: 'chrome',
'goog:chromeOptions': browserOptions,
},
],
};
exports.config = browserConfig;
And this in wdio.conf.ts:
import * as path from 'path';
import * as appRoot from 'app-root-path';
import { commandsFactory } from './commands-factory';
export const config: WebdriverIO.Config = {
specs: [
'./src/features/**/*.feature',
// './src/features/login.feature',
// './src/features/dashboard.feature'
],
exclude: [
],
maxInstances: 1,
logLevel: 'trace',
bail: 0,
baseUrl: 'http://automationpractice.com',
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
services: [
[
'selenium-standalone',
{
logs: 'logs',
},
],
],
outputDir: path.join(appRoot.path, '/logs'),
framework: 'cucumber',
reporters: [
'spec',
[
'allure',
{
outputDir: 'allure-results',
disableWebdriverStepsReporting: true,
disableWebdriverScreenshotsReporting: false,
useCucumberStepReporter: true,
},
],
],
cucumberOpts: {
backtrace: false,
failAmbiguousDefinitions: true,
failFast: false,
ignoreUndefinedDefinitions: false,
name: [],
snippets: false,
source: true,
profile: [],
require: [
'./src/step_definitions/*.ts',
],
snippetSyntax: undefined,
strict: true,
tagExpression: 'not @Login',
tagsInTitle: false,
timeout: 60000,
},
before(capabilities, specs) {
const commands = commandsFactory({ waitForTimeout: this.waitforTimeout });
/* eslint-disable */
const chai = require('chai');
global.should = chai.should();
// Sample command
function browserCustomCommandExample(text) {
console.log(text);
}
browser.addCommand('browserCustomCommandExample', browserCustomCommandExample);
Object.keys(commands).forEach((key) => {
browser.addCommand(key, commands[key]);
});
},
afterStep(step, context, { error, result, passed, duration }) {
if (error) {
browser.takeScreenshot();
}
},
};
But after I do npm install
and try to run tests npm run test:chrome:headless
, I get this error:
[0-0] Error: Failed to create session.
session not created: This version of ChromeDriver only supports Chrome version 85
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'LAPTOP-QUTK6LBV', ip: '192.168.1.8', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_271'
Driver info: driver.version: unknown
I have tried to update version of the driver in wdio.CHROME.conf.ts to 87, but it didn't help.
It just doesn't download version 87 of chrome driver, instead it is stuck with version 85.
When I look at the node_modules\selenium-standalone\.selenium\chromedriver
there is only version 85 and it wouldn't download the version 87 (85 was previous version I had in configuration file).
On my machine, chrome browser version is 87 and it needs the same version of chrome driver in order to work (from my understanding :D )
I tried deleting node_modules
and doing it from scratch but with no success.
This is link to my repo https://github.com/mareru/webdriverIO-shop-demo
Can someone please help :)
Thanks!
I replaced these lines:
const seleniumOpts = config.services?.find(
(service) => Array.isArray(service) && service[0] === 'selenium-standalone'
) as SeleniumStandaloneOptions;
seleniumOpts.args = { ...seleniumConfig };
seleniumOpts.installArgs = { ...seleniumConfig };
With these ones
config.services = [
[
'selenium-standalone',
{
logs: 'logs',
args: seleniumConfig,
installArgs: seleniumConfig,
},
],
];
And it worked. It seems like previous code didn't generate the curly braces well.
Parameters logs, args, installArgs should have been in joint curly brace not in separate curly braces.
It generated this:
[
'selenium-standalone',
{ logs: 'logs' },
args: { version: '3.141.59', drivers: [Object] },
installArgs: { version: '3.141.59', drivers: [Object] }
]
]
While it should have been like this
[
[
'selenium-standalone',
{ logs: 'logs', args: [Object], installArgs: [Object] }
]
]