问题
Is there a way I can get autocomplete on VS Code for webdriverio?
Other code editors like Intellij provide something like Settings -> Preferences -> Languages & Frameworks -> JavaScript -> Libraries From there we can add a directory with webdriverio commands
How can I do similar thing with VS Code?
回答1:
my understanding is, vscode is built with typescript
and by default it does not support autoComplete(Intellisense) on a package that is built with javascript
. So all the js package creators would provide an @types
file. These @types
file help vscode to find all the function definitions, object properties. etc., etc., of your JS package and show as suggestions. Which in case here is webdriverio
package.
So adding a @types
dependency that is related to your JS package will mostly fix the issue.
i.e.,
npm install @types/webdriverio --save-dev
After adding the package, i started getting the browser object suggestions.
回答2:
Above answer worked well :
you need to install below dependency :
if you are using webdriverio v4 (for cucumber BDD ) use below
npm install @types/webdriverio@4 --save-dev
or use :
npm install @types/webdriverio --save-dev
VSCode Intellisense
来源:https://stackoverflow.com/questions/47502115/how-do-i-get-webdriverio-autocomplete-on-vs-code