webdriverio: [🐛 Bug]: `Cannot find name 'browser'.ts(2304)` and `Namespace 'global.WebdriverIO' has no exported member 'Element'.ts(2694)`

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest

Node.js Version

v14.15.1

Mode

WDIO Testrunner

Which capabilities are you using?

No response

What happened?

I just created a default project with latest everything choosing TypeScript and Cucumber. Tests pass, but when I go to the pageobjects fijes I get the following errors:

Namespace 'global.WebdriverIO' has no exported member 'Element' .ts(2694)
Cannot find name '$'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery`.ts(2581)
Cannot find name 'browser'.ts(2304)

What is your expected behavior?

This errors should not be popping.

How to reproduce the bug.

  • Create npm project ( npm init -y )
  • Create wdio project ( npm init wdio )
    • Selected typescript and cucumber
  • Run automatically generated tests -> pass
  • Go to see pageobjects at features/pageobjects
  • See TS errors raise with WebdriverIO.Element and, browser and $ objects:
Namespace 'global.WebdriverIO' has no exported member 'Element' .ts(2694)
Cannot find name '$'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery`.ts(2581)
Cannot find name 'browser'.ts(2304)

Relevant log output

Namespace 'global.WebdriverIO' has no exported member 'Element' .ts(2694)
Cannot find name '$'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery`.ts(2581)
Cannot find name 'browser'.ts(2304)


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

### Is there an existing issue for this?

- [X] I have searched the existing issues

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 23 (4 by maintainers)

Most upvoted comments

~same here 😞~ works using Node 16 and the following tsconfig.json setting:

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

👍🏻

            "@wdio/globals/types",

This resolved my problem, they Removed “webdriverio/async”, and replacted it with “@wdio/globals/types” in WDIO 8 and later.

Already fixed it. Apparently the installer sent my tsconfig and my wdio.conf as well inside a /test/ directory. Never happened to me before. Easy fix though.

~same here 😞~ works using Node 16 and the following tsconfig.json setting:

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

👍🏻

`{

"compilerOptions": {
    "moduleResolution": "node",
    "module": "ESNext",
    "types": [          
        "node","chai",
        "@wdio/globals/types",
        "webdriverio/async",
        "expect-webdriverio",
        "@wdio/cucumber-framework"

    ],
    "typeRoots": ["node_modules/@types"],
    "target": "es2022",
    "esModuleInterop": true,
    "resolveJsonModule": true,
}

}` Still facing this issue. even, edit as yours… above is my tsconfig.json… Is it Correct or need to change anything…