问题
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:
Install protractor as a module of the automation framework (i.e. without
-g
flag)npm install protractor
Run
webdriver-manager update
for this protractor instance as well:node ./node_modules/protractor/bin/webdriver-manager update
Where you have
browser.pause();
in your code, replace it withdebugger;
statementRun your code as follows:
node inspect ./node_modules/protractor/bin/protractor protractorConf.js
Where
protractorConf.js
is the config file of your protractor instanceIf
debugger
waits for an input from you at the command line, just typecont
and hit enter (tocont
inue the execution)
来源:https://stackoverflow.com/questions/23373148/angular-protractor-leave-browser-open-after-e2e-tests