How to make JetBrains webstorm know about `element`, `by` in protractor test spec?

前端 未结 4 1632
既然无缘
既然无缘 2021-01-04 18:09

Right now in my Protractor test spec, Webstorm is complaining that all my element and by are \"Unresolvable type or element\"

相关标签:
4条回答
  • 2021-01-04 18:16

    Have you enabled the TypeScript library for angular-protractor?

    1. Go to Project Settings > Javascript > Libraries
    2. Click Download then select TypeScript community stubs
    3. Find angular-protractor then download and install

    Hope that helps! I know it's not native support but next best thing :-)

    0 讨论(0)
  • 2021-01-04 18:16

    You could localise variable for your scope:

    var element = protractor.element;
    
    0 讨论(0)
  • 2021-01-04 18:33

    Ron H´s Answer worked for me, but i also had to download and install the following packages from the TypeScript community stubs.

    • selenium-webdriver
    • jasmine
    • karma-jasmine

    After that also by.id(), by.className(), iit, ddescribe, toBeTurthy(),... was recognized.

    0 讨论(0)
  • 2021-01-04 18:39

    angular-protractor no longer appears on the list of TypeScript community stubs, presumably because protractor is now officially supported within the WebStorm IDE.

    So, in order to ger protractor code completion:

    1. Install protractor globally: npm install -g protractor
    2. On WebStorm, go to Project Settings > Javascript > Node.js and NPM, and make sure protractor appears in the package list.
    3. On Project Settings > Javascript > Libraries, click the Add... button and point WebStorm to the protractor directory in your global node_modules. In my Mac's case it's /usr/local/lib/node_modules/protractor.
    0 讨论(0)
提交回复
热议问题