Protractor takes blank screenshots when “restartBrowserBetweenTests: true” is set

不想你离开。 提交于 2019-12-24 09:22:08

问题


I'm trying to use protractor-jasmine2-html-reporter to take screenshots of my tests as they run, but it appears to be taking them directly after the browser is restarted due to the "restartBrowserBetweenTests" flag in conf.js being set to "true".

I need to use that flag to restart the browser because it seems to be the only way to clear the session sufficiently so that subsequent tests can use the sign in page, rather than the application assuming it's the same user and redirecting them to the home page. Clearing cookies is not enough.

Screenshot of the html report output with restartBrowserBetweenTests set to true

Screenshot of the html report output with restartBrowserBetweenTests set to false

This is my conf.js file:

    var HtmlScreenshotReporter = require('protractor-jasmine2-html-reporter');

    exports.config = {
        seleniumAddress: 'http://localhost:4444/wd/hub',
        specs: ['./tmp/specs/*.spec.js'],
        restartBrowserBetweenTests: true,

        onPrepare: function() {
          jasmine.getEnv().addReporter(
              new HtmlScreenshotReporter({
                  savePath: 'tmp/screenshots/'
              })
          );
        }

    };

Is there a way I can initiate the screenshot being taken before the browser is restarted? Alternatively, is there a way I can clear the browser's local storage without having to resort to restarting the browser between tests?

Thanks in advance.

来源:https://stackoverflow.com/questions/42909593/protractor-takes-blank-screenshots-when-restartbrowserbetweentests-true-is-se

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