2017-08-23 19 views
2

我已经VS代码配置了这样的量角器调试调试任务:如何用VS代码调试器记录量角器文本元素?

{ 
    "version": "0.2.0", 
    "configurations": [ 
     { 
      "type": "node", 
      "request": "launch", 
      "name": "Debug Tests (Local)", 
      "program": "${workspaceRoot}/node_modules/protractor/bin/protractor", 
      "args": [ 
       "${workspaceRoot}/config/protractor/protractor.conf.override.js" 
      ] 
     } 
    ] 
} 

说我有这个测试:

it('description', function() { 
    expect(this.myPageObject.title.getText()).toEqual('My PO Title'); 
}) 

这一切工作正常,但现在我特林调试这与VS代码。我给自己定的expect线断点和调试工作本身就好了。但是现在我想打印(到调试控制台)this.myPageObject.title.getText()的值。

我知道getText和大多数其他量角器方法返回的承诺,我需要解决这些问题,但我不知道怎么样。以下是我所尝试的:

this.myPageObject.title.getText() 
ElementFinder {browser_: ProtractorBrowser, then: (fn, errorFn) => { … }, parentElementArrayFinder: ElementArrayFinder …} 

this.myPageObject.title.getText().then(console.log) 
ManagedPromise {flow_: ControlFlow, stack_: null, parent_: ManagedPromise …} 

我错过了什么?

回答

0

不幸的是没有很好的解决方案在我脑海

1)尽量把断点进入回调 -

let titleText = this.myPageObject.title.getText().then(text => { 
    return text // Breakpoint here, so you can observe text variable in debug panel 
}) 
expect(titleText).toEqual('My PO Title'); 

2)您可以尝试使用> protractor --elementExplorer终端命令调试,这在开始量角器交互更多,在那里你可以观察到你的行动一步一步

3)你可以尝试使用await this.myPageObject.title.getText()在代码调试终端的断点。没有尝试过,但可能有效。

这是无极经理的一个问题 - 很难调试,所以这就是为什么它不久将被取消。更多信息:http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/promise.htmlhttps://github.com/SeleniumHQ/selenium/issues/2969

+0

1)IMO是违背了使用调试器,如果我不得不改变我的代码,所有的时间只是为了调试的全部目的。 2)我似乎没有这种方式访问​​我的测试环境。 3)没有工作,“等待”没有定义。 –

相关问题