質問

Is there a way I can do the equivalent of "incognito mode" with PhantomJS, where all cookies, local storage, etc., is only transient and does not persist across processes?

This would be useful for UI automation as well as some back-end applications.

役に立ちましたか?

解決

No, there is no such thing out-of-the-box, but at least there are things you can do for some types of data.

Cache and cookies are by default only visible for one phantom instance, but they can be enabled by setting the files for them from the commandline. So you're good here.

The other problematic features are applicationCache, localStorage and webSQLDatabase determined by running modernizr test suite from phantom.

applicationCache is not really a problem as in most cases only public data is cached. It cannot be cleared after each run.

localStorage can be cleared after each run using localStorage.clear() (see here), provided you run your tests sequentially. This might not be the case as you probably use multiple processes in parallel to execute faster. No real solution here.

webSQLDatabase still can not be cleared: How to delete a database in Web SQL?

It's sad to say that there are multiple issues with session handling.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top