【问题标题】:Protractor typescript VScode debugging量角器打字稿VScode调试
【发布时间】:2019-08-28 16:10:17
【问题描述】:

我正在尝试使用打字稿的量角器,并且正在努力使用 VScode 调试测试。

浏览器在测试开始时打开,调试器在调试点停止(在获取 url 和几次点击和 sendkeys 语句之后),但是浏览器是空白的(指定的 url 没有打开,并且没有在浏览器中执行代码的操作!)。当我恢复测试执行时,测试中的所有步骤都会发生!

Launch.json

{
"version": "0.2.0",
"configurations": [

    {
        "type": "node",
        "request": "launch",
        "name": "Working thru node",
        "program": "${workspaceFolder}/node_modules/.bin/protractor",
        "args": [
            "protractor.conf.js"
        ],
        "protocol": "inspector",
        "runtimeArgs": ["--nolazy"],
        "sourceMaps": true,
        "console": "internalConsole",
        "outputCapture": "std"
    }
]}

tsconfig.json

{
    "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "declaration": false,
    "outDir": "output",
    "strict": true,
    "noImplicitAny": false,
    "moduleResolution": "node",
    "types": ["jasmine", "node"],
    "esModuleInterop": true,
    "inlineSourceMap": true,
   },
  "exclude": ["node_modules/*"]
}

配置.ts

import {Config} from 'protractor';
export let config: Config = {

   framework: "jasmine",
   capabilities: {
       browserName: "chrome"
   },
   specs: ["specs/*.js"],
   seleniumAddress: "http://localhost:4444/wd/hub"
};

SampleTest.ts

enter code here
import { browser, element, by, protractor, $ } from "protractor";

describe("Super Calculator", function(){

   beforeEach(function(){
       browser.get("https://juliemr.github.io/protractor-demo/");
   })

   it("Should be able to add two positive numbers", function(){
       element(by.model("first")).sendKeys(1);
       element(by.model("second")).sendKeys(1);
       element(by.id("gobutton")).click();
       var Ec = protractor.ExpectedConditions;
       browser.wait(Ec.not(Ec.presenceOf($(".ng-valid-parse"))));
       expect<any>(element(by.binding('latest')).getText()).toEqual('2');
   })
}) 

运行测试
 npm run tsc && protractor output/config.js  

我的调试点在测试的最后一行,执行在调试点停止,但上述语句中指定的操作均未在浏览器中发生。当我恢复测试时,测试运行并通过了!我期待看到浏览器打开 url 和 sendkeys 并单击在调试点停止执行时发生!任何人都可以帮助我了解问题所在。

【问题讨论】:

    标签: typescript visual-studio-code protractor


    【解决方案1】:

    我是最近在VSCode学习量角器的新人,也遇到了这个问题。这可能与异步有关。我建议在 chrome 检查器中调试, http://www.protractortest.org/#/debugging#disabled-control-flow 。无论如何,在量角器中调试并不像在其他语言中那样容易。

    【讨论】:

      猜你喜欢
      • 2018-03-10
      • 2020-05-17
      • 2016-12-28
      • 2017-04-28
      • 2023-03-23
      • 2016-11-27
      • 2017-12-08
      • 1970-01-01
      • 2018-01-04
      相关资源
      最近更新 更多