Angular Protractor - Leave browser open after E2E tests

两盒软妹~` 提交于 2020-02-26 11:29:31

问题


Is it possible to leave the test browser windows open after Angular Protractor tests run? I have a tough test failing in FireFox and it'd be useful to access the state of the web page to see what's going on.


回答1:


You can use Protractor debug/pause feature to pause the e2e run which will ultimately leave the browser open: more info here

To do so, add this line on your protractor test before the failing one

browser.pause();

There is also a very useful tool called elementor that you may want to take a look later on.




回答2:


browser.pause no longer works with current Node v8.1.0, see here, but you could use browser.sleep(10000); to keep the browser open for e.g. 10 seconds




回答3:


If you configured the test script to run using grunt, you could use the following code:

grunt.initConfig({
    // ...
    protractor: {
      options: {
        configFile: "protractor.conf.js",
        keepAlive: true, // If false, the grunt process stops when the test fails.
        noColor: false // If true, protractor will not use colors in its output.
      },
      run: {}
    },
    // ...
  });



回答4:


If you have Node 8+, bumped into issue "Error: Cannot find module '_debugger'" while attempting browser.pause solution from the accepted answer and you couldn't fix it using this github solution then you can workaround it as follows:

  1. Install protractor as a module of the automation framework (i.e. without -g flag)

    npm install protractor
    
  2. Run webdriver-manager update for this protractor instance as well:

    node ./node_modules/protractor/bin/webdriver-manager update
    
  3. Where you have browser.pause(); in your code, replace it with debugger; statement

  4. Run your code as follows:

     node inspect ./node_modules/protractor/bin/protractor protractorConf.js
    

    Where protractorConf.js is the config file of your protractor instance

  5. If debugger waits for an input from you at the command line, just type cont and hit enter (to continue the execution)



来源:https://stackoverflow.com/questions/23373148/angular-protractor-leave-browser-open-after-e2e-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!