Update Network
Predefined network condition usage
updateNetwork(networkMode);
Updates network conditions for participant while the test is running.
The networkMode
parameter specifies what network conditions should be used.
Available network configurations and networkMode
values can be found
here
or they can be accessed using constants.
public void testUIWithLoadero() {
// Example of updating network conditions using constants
open("https://www.bing.com");
E(byCssSelector(".dimmer"))
.waitFor(10).untilIsVisible();
// Update network condition to mobile 4G value
updateNetwork(loaderoConstants.getNetwork().getMobile4G());
}
Custom network condition usage
There is also an option to create custom network conditioner configuration and
pass that instead into updateNetwork()
command.
updateNetwork(Conditioner config);
There are several ways to create custom configuration. One way of doing it is to
create Conditioner
variable and use setters to set specific fields.
Conditioner config = new Conditioner();
config.setLatencyUp(10);
Currently available custom network configuration metrics are:
Network parameter | Traffic direction | Setter function | Unit of measure | Min value | Max value |
---|---|---|---|---|---|
Bandwidth | Outgoing | setRateUp() | mbit | 0 | |
Incoming | setRateDown() | mbit | 0 | ||
Latency | Outgoing | setLatencyUp() | ms | 0 | |
Incoming | setLatencyDown() | ms | 0 | ||
Jitter | Outgoing | setJitterUp() | ms | 0 | |
Incoming | setJitterDown() | ms | 0 | ||
Packet loss | Outgoing | setLossUp() | % | 0 | 100 |
Incoming | setLossDown() | % | 0 | 100 |
Also there is an option to create this configuration using command chaining using build pattern like this:
Conditioner config = new ConditionerBuilder().latency(20, 10).buildConditioner();
For custom network configuration jitter parameters must be defined together with latency. If jitter parameters are set without also defining latency parameters, then jitter configuration will not be applied.
The network parameters not defined in custom network configuration will be reset to their default values.
These are available ConditionerBuilder
methods:
.latency(up, down)
.latencyUp(up)
.latencyDown(down)
.jitter(up, down)
.jitterUp(up)
.jitterDown(down)
.rate(up, down)
.rateUp(up)
.rateDown(down)
.loss(up, down)
.lossUp(up)
.lossDown(down)
public void testUIWithLoadero() {
// Example of updating network conditions using custom network configuration
open("https://www.bing.com");
Conditioner config = new ConditionerBuilder()
.latency(10, 10)
.buildConditioner();
updateNetwork(config);
config.setRateUp(20);
updateNetwork(config);
}