The common misconception while people designing any automation framework is that it is designed to run in the testing environment with wider broadband and adequate internet, which in real time it will not be the case, a common user may not be having enough bandwidth at all times. So at this time the application should respond the user’s requests without giving timeout errors or make the application stall with delayed responses ,
As a common use case most cases people while travelling needs to check their current location or need to share their live location, at these instances even though the application is slow it should not stall the user or decline the requests, Of course the performances of API would be real factor here, but even though API responses are really up to the mark (which by the way there are options to evaluate the performance using many tools, JMeter is one such tool).
People don’t really make an effort to check how the user interface of the application responds according to the poor network, throughout our lives we have seen many of our application stalls or loads indefinitely irks us time to time. Since it’s been always a niche topic , Selenium Remote provides an option to apply Network throttling on top of browser session.
If you see in the above code, we are using Command Executor from selenium remote to apply network throttling
- Line no 27 : offline=false, means the internet connectivity will be turned off for the session, this will help if we want to test the disconnected internet in between the session and ability of the user to continue the same session when the internet becomes up again.
- Line no 28 : latency=60, means adding more latency (ms) in the network.
- Line no 29 : download_throughput=10000, means the 10000 bytes per second download throughput is applied in the network, even though the network has more bandwidth , it is now limited to 10000 bytes per second (0.01 Mbps).
- Line no 30 : upload_throughput=10000, means the 10000 bytes per second upload throughput (bytes) is applied in the network, even though the network has more bandwidth , it is now limited to 10000 bytes per second (0.01 Mbps).
GitHub repo link : https://github.com/vigneshram20/NetworkThrottlingUsingSelenium
Clone the repository and change the chrome driver path, That’s it, You can change the throughput values between 1 bytes and any upper value, Remember the more value you provide the more throughput you will be getting(speed), And also if you increase the throughput to maximum value it would not necessarily increase the network throughput beyond your bandwidth.
Confused about latency, throughput, bandwidth and stuff? Don’t worry! I have created a dedicated post explaining in simple terminologies , Please erudite yourself.
Meet you in the next quirky post, adieu.👋