如何在grunt-protractor-runner v5、protractor v4.0.14和node v8.13中配置调试。

问题描述 投票:0回答:1

我最近转入了一个项目,要重新架构我们整个企业的protractor代码库。我们使用node v8.13、protractor v4.0.14和grunt-protractor-runner v5。

以下是我如何配置......

vscode launch.json

        {
            "type": "node",
            "request": "launch",
            "name": "Pro Debug",
            "program": "${workspaceRoot}/node_modules/protractor/bin/protractor",
            "args": ["${workspaceRoot}/ConvertedJSFiles/tests/config/conf.js"],
        }

grunt.js

default: {
      options: {
        keepAlive: true,
        debug: true
      }
    },

示例测试.ts

  it( '2@Click in Sign in to your account', async function () {
    browser.pause();
    debugger;

    await commonMethods.beforeAll();

    landingPage.logIn();
    expect( browser.getCurrentUrl() ).toContain( 'login' ); 
  } );

当我试图在chrome中调试时,我用 "grunt "命令执行。测试似乎在我输入 "debugger "语句的地方失败了。

>> (node:13476) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
>> Debugger listening on ws://127.0.0.1:9229/ff1f9827-a76b-4400-9d0e-b0cec6912508
>> For help see https://nodejs.org/en/docs/inspector
>> (node:13477) [DEP0068] DeprecationWarning: `node debug` is deprecated. Please use `node inspect` instead.
>> Port 9229 is already in use. Please specify another port to debug.

我想这可能是由于vscode在没有启动protractor的情况下执行conf.js造成的。

[16:57:06] E/runner - Unable to start a WebDriver session.
logger.js:170
[16:57:06] E/launcher - Error: UnsupportedOperationError: unknown command: Cannot call non W3C standard command while in W3C mode
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'US8525RT.local', ip: 'fe80:0:0:0:cdc:1e02:9f9f:9858%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.4', java.version: '1.8.0_241'
Driver info: driver.version: unknown
    at Object.checkLegacyResponse (/Users/jayce.tan/Code/ui-automation-ts/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:639:15)

任何帮助都将是非常感激的。

protractor gruntjs
1个回答
1
投票

像这样尝试

注意:如果你使用outfolder来构建ts文件到js,请修改路径。

启动.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "stopOnEntry": false,
            "program": "${workspaceRoot}/node_modules/protractor/bin/protractor",  // path the protractor node modules.
            "args": [
                "${workspaceRoot}/build/config/config.js" // path to compiled protractor configuration file.
            ],
            "preLaunchTask": null,
            "sourceMaps": true,
            "outFiles": [ "${workspaceRoot}/build/**/*.js" ]
        }
    ]
}

之后在visual studio代码中设置断点,调试程序。

如果你还是有问题,只要禁用W3C就可以了。

Proractorconfig.js注意:根据你的需要调整它,这只是如何禁用w3c的例子。

capabilities: {
   browserName: 'chrome',
   'goog:chromeOptions': {
       w3c: false,
       args: [] // args if required.
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.