Webdriver.io autocomplete not functioning since 2019.3.2
Hi,
I am finding that since the update I am not getting autocomplete options for NPM module WebdriverIO. Loading up in VSCode and it still works in there, so I am thinking something must have gone wrong with my Webstorm config. I have tried: 'File > Invalidate Caches/Restart > Invalidate and Restart' but no luck, I have also created a fresh project from scratch and installed my necessary components, but no luck.
Please sign in to leave a comment.
Please can you share code snippets (as text)/files the issue can be reproduced with?
In recreating this I have discovered that it is working for an element within the test, but not an element from a pageobject.
In the code below autocomplete functioned for `element`, but not for `Account.backButton`. The same is not true in VSCode where it autocompletes in both:
```
import Account from "../../Pages/Account";
describe('Test', () => {
it('should test something', () => {
browser.url("/");
const element = $('Some_element');
element.click();
Account.backButton.click();
});
});
```
**Expected behavior**
Autocomplete should function for a getter the same as any element does.
An issue has been raised with WebdriverIO as well:
https://github.com/webdriverio/webdriverio/issues/5054
what does Account module definition/export look like? Please provide a complete, self-containing code snippet
The getter on the page object page would look like this:
import Page from './Page'
class Account extends Page {
get backButton() {
return $("Some_element");
}
}
export default new Account();
A self contained example would be:
import Page from './Page'
class Account extends Page {
get backButton() {
return $(".button.button--grey");
}
}
testGetter() {
this.backButton.click();
}
export default new Account();
works fine for me using your example:
does caches invalidation help?
Your example shows autocomplete for the getter name working, that is working for me also.
I can't get the WebdriverIO commands to autocomplete, for example where the click is on line 7, changing that to selectBy should autocomplete with selectByAttribute (and other commands starting with selectBy).
Cache invalidation didn't help
>I can't get the WebdriverIO commands to autocomplete, for example where the click is on line 7, changing that to selectBy should autocomplete with selectByAttribute (and other commands starting with selectBy).
you should have mentioned it explicitly/update your code snippet accordingly.
As it's suggested in https://github.com/webdriverio/webdriverio/issues/5054#issuecomment-590329310? you need adding JSDoc annotations to let the IDE know what type is expected
it doesn't work in VSCode either, BTW:
BTW it does work in vscode if you follow the configuration instructions here https://webdriver.io/docs/autocompletion.html
...and it did work in webstorm untill recently. Yes declaring the type will make it work, that doesn't change the fact that this used to work without declaring type for every getter.