I need to test a feature of my app designed to execute in offline mode, using local storage to queue data before internet connectivity is restored. Can Selenium set browser in offline mode?
1 Answer
You can create the new Browser Profile say for firefox. and then configure that profile to use offline mode using :
network.manage-offline-status with the value true.
3 Comments
lairtech
Can I set the profile dynamically? I want to simulate a scenario where the app loses connectivity during usage.
Nathan Merrill
No. Profiles are set at the beginning only. You could try other non-selenium tricks to lose connection, however (if you are going to run selenium remotely, that won't work).
Gábor Lipták
If you try this, you will get the following exception: java.lang.IllegalArgumentException: Preference network.manage-offline-status may not be overridden: frozen value=false, requested value=true