使用WebStorm调试量角器

通尼奥

我正在尝试使用WebStorm来调试量角器e2e测试,我的目标是能够在测试代码中放置断点。我是新来的,所以我可能做错了什么。

量角器教程所述,我更新了webdriver-manager并在cmd终端中使用此命令启动它(我在Windows上工作):

webdriver-manager start

这是我的protractor-conf.js文件:

var ScreenshotReporter = require('./screenshotReporter.js');

exports.config = {
  // The address of a running selenium server.
  seleniumAddress: 'http://localhost:4444/wd/hub',

  //baseUrl: 'http://localhost:9000',

  framework: 'jasmine2',

  // Capabilities to be passed to the webdriver instance.
  capabilities: {
    'browserName': 'chrome'
  },

  specs: ['**/*_spec.js'],

  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000
  },

  onPrepare: function() {
    jasmine.getEnv().addReporter(new ScreenshotReporter("test-e2e/screenshotFailures/"));
  }
};

我在WebStorm中创建了这样的配置:

节点解释器: C:\ Program Files \ nodejs \ node.exe

工作目录: C:******* \ ref-app

Javascript文件: node_modules \ protractor \ lib \ cli.js

应用程序参数: test-e2e / protractor-conf.js

在我尝试了几件事之后:

  1. 使用WebStorm中的“运行”按钮运行Protactor:失败:在页面上找不到Angular /:重试查找超出角度
  2. 使用WebStorm中的“调试”按钮调试量角器:我可以在WebStorm控制台中看到它,但是在以下情况下什么也没发生:

    Using the selenium server at http://localhost:4444/wd/hub
    [launcher] Running 1 instances of WebDriver
    Started
    F
    
  3. 修改protractor-conf.js以添加baseUrl

    baseUrl: 'http://localhost:9000',
    

    然后启动一个本地网络服务器上的端口9000
    如果我在WebStorm使用运行按钮运行量角器,它工作正常,但我不能设置断点,
    如果我调试Prtoractor使用Debug按钮在WebStorm,我可以看到这个控制台,但没有发生后:

    Using the selenium server at http://localhost:4444/wd/hub
    [launcher] Running 1 instances of WebDriver
    Started
    

编辑:正如我在下面的评论中所说,我正在使用:量角器3.1.0 WebStorm 11.0.3

当我尝试使用Webstorm进行调试时,它打开了一个Chrome窗口,但屏幕完全空白,并且在URL中,您有:data: ,, (我认为这没有用,但我不知道该怎么做)

知道我在做什么错吗?

迈克尔·R。

您可以在--inspect-brk模式下运行node ,并附加一个远程调试器,例如chrome dev-tools:

使用启动您的应用程序ng serve并运行

node --inspect-brk ./node_modules/protractor/bin/protractor ./protractor.conf.js

现在,节点等待调试器附加。

然后就可以打开了chrome://inspect/#devices您的应用应该会出现。最后,在目标/您的应用程序上单击检查,瞧,您现在可以使用断点和debugger;语句了。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章