1

I'm getting this WebStorm warning:

Method expression is not of Function type.
Missing import statement.
Insert 'import {element} from "Protractor"'

I am not getting the warning for the element.all shown here:

 localB.patientData = function(b, no) {
            switch(b) {
                case 'personalHistoryAdd':
                    return element.all(by.css('#\\31 3f65373-7f31-4581-b839-8281e0d5dd0d > button')).get(0);
                case 'familyHistoryAdd':
                    return element.all(by.css('#\\31 3f65373-7f31-4581-b839-8281e0d5dd0d > button')).get(1);
                case 'surgicalHistoryAdd':

            }};

But I do get it for element here:

        localB.vitals = function(b, no) {
            switch(b) {
                case 'heightInput':
                    return element(by.css('#height'));
                case 'weightInput':
                    return element(by.css('#weight'));
                case 'temperatureInput':
                    return element(by.css('#temp'));
            }
        };

These are in the same file. TLDR, I do not get the warning with element.all but I do get it with just element, which is really odd!

It fixes it if I add Insert 'import {element} from "Protractor"' at the beginning of the file but the script won't execute, so this is not a solution.

Isn't it a possibility to configure WebStorm to fix this?

This is how WebStorm/Libraries looks like, for me:

ON  @types/jasmine  Global
ON  @types/jest Global
ON  @types/karma    Global
ON  @types/mocha    Global
ON  @types/node Global
ON  @types/protractor-helpers   Global
ON  @types/selenium-standalone  Global
ON  @types/selenium-webdriver   Global
ON  protractor  Global
ON  selenium    Global
ON  selenium-webdriver  Project
ON  HTML    Predefined
ON  HTTP Response Handler   Predefined
ON  Node.js Core    Predefined
ON  wbk-automation-protractor/node_modules  Predefined

If I disable these:

ON  protractor  Global
ON  wbk-automation-protractor/node_modules  Predefined

Then I get the Missing Import Statement for by.css as well, for example.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
tudorsss
  • 11
  • 4
  • I got this response from Webstorm: in protractor typings, element is defined as a ES6 module, and thus has to be imported, so this warning is correct and expected (same is true for by, browser, etc.). You can disable JavaScript | General | Missing import statement inspection in Preferences | Editor | Inspections, or suppress it for needed statements by adding // noinspection ES6ModulesDependencies comment above them But by and browser, they work. It's just element. I'm waiting for a reply from them. – tudorsss Apr 04 '19 at 12:33

0 Answers0