Skip to main content

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 parameterTraffic directionSetter functionUnit of measureMin valueMax value
BandwidthOutgoingsetRateUp()mbit0
IncomingsetRateDown()mbit0
LatencyOutgoingsetLatencyUp()ms0
IncomingsetLatencyDown()ms0
JitterOutgoingsetJitterUp()ms0
IncomingsetJitterDown()ms0
Packet lossOutgoingsetLossUp()%0100
IncomingsetLossDown()%0100

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();
info

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.

info

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);
}