ExplorifyStack, WebDriveIO, CukeIt, TypewiseScript

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 >>>');
  }
};

https://i.sstatic.net/2YA92.png

https://i.sstatic.net/9jJa1.png

Answer №1

Consider including 'wdio-cucumber-framework' in the types section of your tsconfig.json configuration file

Answer №2

Although this response comes a bit later, it seems that the issue lies in the types you have specified. As per the webdriver.io documentation, you should only include either webdriverio or @wdio/sync in your types, but not both.

When using sync mode (@wdio/sync), you need to replace webdriverio types with @wdio/sync.

Avoid importing webdriverio or @wdio/sync explicitly. TypeScript definitions for WebdriverIO and WebDriver can be accessed globally once added to the types in tsconfig.json.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Encountering an error in Angular where the property does not exist in type

Struggling to create a collapsible menu within my header component in an Angular project, I've hit a snag with proper JSON formatting. The error message that keeps popping up reads: Error: src/app/components/header/header.component.html:48:49 - error ...

Exploring Angular 4's capability: Incorporating data from Http Post Response into a .js file or highchart

I'm a beginner with Angular 4. I'm trying to create a dashboard that pulls data from an Http Post Response and I want to use this data to create a Chart (Highchart). I have successfully received the response in the console.log and formatted it i ...

Issue with passing parameters to function when calling NodeJS Mocha

I have the following function: export function ensurePathFormat(filePath: string, test = false) { console.log(test); if (!filePath || filePath === '') { if (test) { throw new Error('Invalid or empty path provided'); } ...

What is the best way to retrieve an object within a class?

Exploring a Class Structure: export class LayerEditor { public layerManager: LayerManager; public commandManager: CommandManager; public tools: EditorTools; constructor() { this.commandManager = new CommandManager(); this.lay ...

Retrieving Data from Local Storage in Angular and Showing Results

I am having trouble displaying values from a list stored in localStorage when using a multi-select mat-button-toggle-group. The value appears empty on my page. What could be the issue? I am using a mat-button-toggle-group with a (change) trigger and defau ...

Error message: Custom binding handler failed: 'Flatpickr' is not a valid constructor

Trying my hand at creating a custom binding handler in knockout for Flatpickr has hit a snag. Upon attempting to use it, an error is thrown: Uncaught TypeError: Unable to process binding "datetimepicker: function (){return startDate }" Message: Flatpickr ...

Posting an array as form data in Angular Typescript: A step-by-step guide

Hello there, I'm currently developing an application using Angular 8 and integrating web.api within .net core 2.2. One of the challenges I encountered is dealing with multi-selectable checkboxes in a form that also includes "regular" inputs and file ...

Navigating TS errors when dealing with child components in Vue and Typescript

Recently, I encountered an issue where I created a custom class-based Vue component and wanted to access its methods and computed properties from a parent component. I found an example in the Vue Docs that seemed to address my problem (https://v2.vuejs.org ...

Error TS2322: Type 'Partial<T>' is not assignable to type 'T'

I'm struggling to articulate my problem, so I think the best way to convey it is through a minimal example. Take a look below: type Result = { prop1: { val1: number, val2: string }, prop2: { val1: number } }; f ...

Using Jest and Supertest for mocking in a Typescript environment

I've been working on a mock test case using Jest in TypeScript, attempting to mock API calls with supertest. However, I'm having trouble retrieving a mocked response when using Axios in the login function. Despite trying to mock the Axios call, I ...

Challenges with sorting and pagination in Angular 6's material-table

I am facing a challenge in my Angular6 material-data-table application where I need to display and manipulate a complex JSON structure received from a REST endpoint. While the data is successfully displayed, I am struggling to implement pagination and sort ...

Adding onBlur validation for radio buttons and checkboxes in Angular Material UI

Currently, I am working on implementing checkboxes and radio buttons using Angular Material UI. My main issue lies in achieving the desired red outline effect when a required field is left unselected by the user. Even after applying the necessary 'req ...

The 'filter' attribute is not found in the 'ContextProps' type

I am currently working on a project in Next.js 13 where I am trying to render card items conditionally based on their status. The TypeScript version being used is "5.2.2". However, I encountered an error that says: Property 'filter' does not exis ...

Can you identify the nature of the argument(s) used in a styled-component?

Utilizing typescript and react in this scenario. Fetching my variable const style = 'display: inline-block;' Constructing a simple component export const GitHubIcon = () => <i className="fa-brands fa-github"></i> Enh ...

Execute the cucumber tests based on tags or run all the tests

I am facing challenges when it comes to running cucumber tests. I aim to execute either all scenarios if tags are not provided as a CLI argument, or specific scenarios based on the passed tags as CLI arguments. Here is my configuration file: module.exports ...

The Angular AJAX call was unsuccessful due to the Content-Type request header field being forbidden by the Access-Control-Allow-Headers in the preflight response

Here is the code I am using to send a post request from Angular 6 to my web service. const headers = new HttpHeaders({ 'Content-Type': 'application/json' }); const headeroptions = { headers: headers }; return this.http.post(this. ...

Continuously converting methods recursively until the array is fully processed

My current code has a method that is not very efficient and does not scale well. The object y is an array consisting of key/value pairs, each containing two properties: 1. A unique string property called name. This value is identified by the childre ...

What is the solution for positioning a checkbox above a label in ngx-formly?

The checkbox control is displayed on top of the label. The control is defined as follows: { key: 'selected', type: 'checkbox', templateOptions: { label: 'Virtual Bollo', indet ...

The language translation in Angular 6 remains static and unchanged until the page is refreshed

My website supports 5 different languages with English as the default. When I switch languages in the header component... header.component.ts onSetLanguage(lang: string) { this.trans.use(lang); this.currentLang = localStorage.setItem("currentLa ...

What could be the rationale behind the optional chaining operator not being fully compatible with a union of classes in TypeScript?

Imagine I have a combination of classes: type X = ClassA | ClassB | ClassC; Both ClassA and ClassC have a shared method called methodY. Why is it that I can't simply use the optional chaining operator to call for methodY? class ClassA { methodY ...