I would like to have an automated test for the following scenario:
- User logs in and performs some "lengthy" operation. For example tries to upload a file.
- In the middle of that lengthy operation, the connection to the server is lost for a period of time, and then restored.
- Application does whatever it's supposed to do in this case. For example shows a message to the user asking if they want to retry.
I want steps 1. and 3. to be done by Selenium. Question is: how can I do the step 2. as part of the automated test?
Details on the tools and environment:
- Selenium is on Java with Junit
- Test must run on Linux and Windows
- It will also run on 3 browsers: Firefox, Chrome, IE 11
Couple of solutions I was thinking about:
- Call some script that manipulates a connection on the machine.
- Manipulate proxy settings of the browser (proxy points to fake address, thus connection is broken).
- Use a real proxy, which could be controlled from the code (e.g. by some commands), so it can behave as "working" or "broken" connection.
None of these solutions is ideal for various reasons.
So: did anyone try to solve a similar problem? Would like to hear your solution or alternative ideas, that you think may work. Thanks.