view console.log output in angular protractor jasmine test

后端 未结 7 1839
忘掉有多难
忘掉有多难 2020-12-24 05:12

How can I view console.log output in an angularjs protractor jasmine test? As of now, the browser closes by itself too quickly.

more info - I am working with the ang

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-24 06:09

    In order to keep the browser's window open you should try running Protractor in debug mode:

    $  debug 
    

    Then in your spec file add this line where you want the execution to stop:

    browser.debugger();
    

    In the Protractor debugger console, you can step over the stops by typing c or cont.

    More info here: https://github.com/angular/protractor/blob/master/docs/debugging.md

    Now, in order to get the console content you can check how to do it in Protractor FAQ: https://github.com/angular/protractor/blob/master/docs/faq.md#how-can-i-get-hold-of-the-browsers-console

    Something like:

    browser.manage().logs().get('browser').then(function(browserLog) {
      console.log('log: ' + require('util').inspect(browserLog));
    })
    

提交回复
热议问题