0

I have followed the instructions for configurating WebDriverIO (and Mocha) for a TypeScript. Specifically to: install tsx;

$ npm install tsx --save-dev

and include the following in tsconfig.ts;

{
    "compilerOptions": {
        "types": [
            "node",
            "@wdio/globals/types",
            "@wdio/mocha-framework",
        ]
    }
}

And yet the follwing:

import { browser } from '@wdio/globals'

describe('Electron', () => {
    it('Should print title', async () => {
        const title = await browser.getTitle()
    })
})

produces this error:

Property 'getTitle' does not exist on type 'Browser'.ts(2339)
any

As the compile understands browser to be:

interface Browser {}

WebDriverIO TypeScript guide: https://webdriver.io/docs/typescript/

1
  • This is no way an answer, but having made some changes elsewhere, the browser object is now partially typed (ie browser.getTitle is recognised, but browser.electron is not). my guess is the subsequent inclusion of @wdio/globals in the dev dependencies in package.json has helped, but can't say for sure Commented Jan 30 at 16:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.