WebStorm在Protractor测试规范中不识别`browser`,`element`等

时间:2017-09-22 18:56:07

标签: jasmine protractor webstorm jetbrains-ide

关注Protractor guide我想创建我的第一个测试。虽然测试工作不幸但JetBrains WebStorm无法识别给定测试中的所有变量

WebStorm view

我已在库/ JavaScript中启用:

  1. 茉莉
  2. 业力
  3. 果报茉莉
  4. HTML
  5. Node.js Core
  6. 硒的webdriver
  7. 如上所示,启用了Node.js核心库。

    我也访问了this question,但不幸的是角度量角器不再可用。

    我错过了什么?

2 个答案:

答案 0 :(得分:1)

如果导入,您的编辑会理解它。它会知道在哪里找到<html> <script type="text/javascript"> var canvas, ctx, flag = false, prevX = 0, currX = 0, prevY = 0, currY = 0, dot_flag = false; var x = "black", y = 2; var saveTimer; function onSaveTimer() { save(); } function init() { canvas = document.getElementById('can'); ctx = canvas.getContext("2d"); w = canvas.width; h = canvas.height; canvas.addEventListener("mousemove", function (e) { findxy('move', e) }, false); canvas.addEventListener("mousedown", function (e) { findxy('down', e) }, false); canvas.addEventListener("mouseup", function (e) { findxy('up', e) }, false); canvas.addEventListener("mouseout", function (e) { findxy('out', e) }, false); // saveTimer = setInterval(onSaveTimer, 3000); } function color(obj) { switch (obj.id) { case "black": x = "black"; break; case "white": x = "white"; break; } if (x == "white") y = 14; else y = 2; } function draw() { ctx.beginPath(); ctx.moveTo(prevX, prevY); ctx.lineTo(currX, currY); ctx.strokeStyle = x; ctx.lineWidth = y; ctx.stroke(); ctx.closePath(); } function erase() { var m = confirm("Want to clear"); if (m) { ctx.clearRect(0, 0, w, h); document.getElementById("canvasimg").style.display = "none"; } } function save() { document.getElementById("canvasimg").style.border = "2px solid"; var dataURL = canvas.toDataURL(); if (dataURL) { document.getElementById("canvasimg").src = dataURL; document.getElementById("canvasimg").style.display = "inline"; return true; // will POST form to the server } return false; // will not POST to server } function findxy(res, e) { if (res == 'down') { prevX = currX; prevY = currY; currX = e.clientX - canvas.offsetLeft; currY = e.clientY - canvas.offsetTop; flag = true; dot_flag = true; if (dot_flag) { ctx.beginPath(); ctx.fillStyle = x; ctx.fillRect(currX, currY, 2, 2); ctx.closePath(); dot_flag = false; } } if (res == 'up' || res == "out") { flag = false; } if (res == 'move') { if (flag) { prevX = currX; prevY = currY; currX = e.clientX - canvas.offsetLeft; currY = e.clientY - canvas.offsetTop; draw(); } } } </script> <body onload="init()"> <canvas id="can" width="500px" height="675px" style="position:absolute;border:2px solid;"></canvas> <div style="position:relative;top:40px;left:600px;">Eraser</div> <div style="position:relative;top:50px;left:600px;width:15px;height:15px;background:white;border:2px solid;" id="white" onclick="color(this)"></div> <div style="position:relative;top:100px;left:600px;width:15px;height:15px;background:black;border:2px solid;" id="black" onclick="color(this)"></div> <div style="position:relative;top:50px;left:600px;">Pen</div> <form method="POST" action="" onsubmit="save"> <img id="canvasimg" style="position:relative;top:10%;left:600px;" style="display:none;"> </form> <input type="button" value="save" id="btn" size="30" onclick="save()" style="position:relative;top:150px;left:594px;"> <input type="button" value="clear" id="clr" size="23" onclick="erase()" style="position:relative;top:180px;left:550px;"> </body> </html> ot browser

在文件顶部添加import语句。

by

答案 1 :(得分:0)

使用JS Hint RC。它将像魔术一样工作。 你可以通过转到

找到这个
  

设置 - &gt;语言和框架 - &gt; Javascript(选择ECMA脚本6) - &gt;代码质量工具 - &gt; JS提示 - 启用,使用配置文件。

对于配置文件,请保存以下名称的波纹管文件:'。。jshintrc'。

如果这对您有用,请将答案评为正数!

{
  "jasmine": true,
  "mocha": true,
  "esversion":6,
  "loopfunc": true,
  "node": true,
  "globals": {
    "esversion": 6,
    "angular": false,
    "browser": false,
    "inject": false,
    "_": false,
    "driver": false,
    "protractor": false,
    "$": false,
    "$$": false,
    "element": false,
    "by": false,
    "list": false
  }
}