I'm currently working on setting up my automation tests using Cucumber, TypeScript, WebdriverIO, and BrowserStack.
It seems like there is no recent setup guide available for this particular stack, and I've run into some issues with TypeScript. Despite configuring all the necessary settings and features for the tests, I keep encountering a TypeScript error:
Error:(7, 54) TS2339: Property 'element' does not exist on type 'BrowserObject'.
I suspect there might be an issue with the TypeScript configuration.
Can anyone help me identify what might be going wrong?
tsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"outDir": "./tsrc",
"strict": true,
"typeRoots": [ "./node_modules/@types" ],
"types": [
"node",
"chai",
"@wdio/sync",
"webdriverio",
"cucumber"
],
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
},
"exclude": [
"node_modules",
"./tests/tsrc"
],
"compileOnSave": false
}
wdio.conf.js
exports.config = {
// Configuration settings for BrowserStack
user: process.env.BROWSERSTACK_USER_NAME,
key: process.env.BROWSERSTACK_KEY,
// Specify the test files to be run
specs: [
'./tests/features/*.feature'
],
exclude: [],
// Capabilities for testing
capabilities: [{
maxInstances: 1,
browserName: 'chrome'
}],
// Test configuration settings
sync: true,
logLevel: 'verbose',
coloredLogs: true,
deprecationWarnings: true,
bail: 0,
screenshotPath: './errorShots/',
baseUrl: 'http://localhost:3000',
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
services: ['browserstack'],
framework: 'cucumber',
reporters: ['spec', 'junit'],
cucumberOpts: {
require: ['./tests/steps/*.ts'],
backtrace: false,
compiler: ['ts:ts-node/register'],
dryRun: false,
failFast: false,
format: ['pretty'],
colors: true,
snippets: true,
source: true,
profile: [],
strict: false,
tags: [],
timeout: 20000,
ignoreUndefinedDefinitions: false
},
onPrepare: function (config, capabilities) {
console.log('<<< BROWSER TESTS STARTED >>>');
},
before: function (capabilities, specs) {
require('ts-node').register({ files: true });
},
onComplete: function(exitCode, config, capabilities) {
console.log('<<< BROWSER TESTING FINISHED >>>');
}
};