diff --git a/docs/dev/test-configuration-options.md b/docs/dev/test-configuration-options.md index 1515ddd00f..760ad81f0c 100644 --- a/docs/dev/test-configuration-options.md +++ b/docs/dev/test-configuration-options.md @@ -1603,6 +1603,38 @@ Each network condition has a supported value range: --- +### `sauce: network-profile` + +
| OPTIONAL | STRING | Real Devices Only |
+ +Set a network profile with predefined network conditions dynamically during your session. +Please refer to the [list of network profiles](/mobile-apps/features/network-throttling/#predefined-network-profiles) for more information about each profile's network conditions. + +```java +driver.executeScript("sauce: network-profile", "2G"); +``` + +--- + +### `sauce: network-conditions` + +| OPTIONAL | OBJECT | Real Devices Only |
+ +Set custom network conditions for `downloadSpeed`, `uploadSpeed`, `latency` or `loss` dynamically during your session. +Not all parameters need to be specified and only the ones specified will have conditioning applied. +Please refer to [Network Throttling - executeScript](/mobile-apps/features/network-throttling/#appium---executescript) for more information. + +```java +driver.executeScript("sauce: network-conditions", ImmutableMap.of( + "downloadSpeed", 5000, + "uploadSpeed", 3000, + "latency", 200, + "loss", 2, +)); +``` + +--- + ### `mobile: shell`| OPTIONAL | STRING | Real Devices Only | Android Only |
diff --git a/docs/mobile-apps/features/network-throttling.md b/docs/mobile-apps/features/network-throttling.md index 512bf75be1..f01978f281 100644 --- a/docs/mobile-apps/features/network-throttling.md +++ b/docs/mobile-apps/features/network-throttling.md @@ -143,18 +143,84 @@ The following table shows the predefined network profiles along with their corre ## Automated Testing -### Appium -To use the Sauce Labs Network Throttling feature in your automated Appium test, you can add the sauce-specific capability +### Appium - Capability +To use the Sauce Labs Network Throttling feature in your automated Appium test, you can add the Sauce-specific capability [networkConditions](https://docs.saucelabs.com/dev/test-configuration-options/#networkconditions) to provide custom network conditions for the entire session. -Alternatively, you can use the sauce-specific capability [networkProfile](https://docs.saucelabs.com/dev/test-configuration-options/#networkprofile) +Alternatively, you can use the Sauce-specific capability [networkProfile](https://docs.saucelabs.com/dev/test-configuration-options/#networkprofile) to apply one of the predefined network profiles to your session. +```java +MutableCapabilities capabilities = new MutableCapabilities(); +//... +MutableCapabilities sauceOptions = new MutableCapabilities(); + +// network conditions +sauceOptions.setCapability("networkConditions", ImmutableMap.of( + "downloadSpeed", 5000, + "uploadSpeed", 3000, + "latency", 200, + "loss", 2, +)); + +// OR + +// network profile +sauceOptions.setCapability("networkProfile", "2G"); + +capabilities.setCapability("sauce:options", sauceOptions); +``` + +### Appium - executeScript + +To change your desired network conditions dynamically any time during your automated Appium test, use our Sauce-specific scripts +[sauce: network-conditions](/dev/test-configuration-options/#sauce-network-conditions) and [sauce: network-profile](/dev/test-configuration-options/#sauce-network-profile) with +[Appium's Execute Script](https://appium.io/docs/en/2.0/guides/execute-methods/). + + + +```java title="Dynamically set Network Conditions" +driver.executeScript("sauce: network-conditions", ImmutableMap.of( + "downloadSpeed", 5000, + "uploadSpeed", 3000, + "latency", 200, + "loss", 2, +)); +``` + +```java title="Dynamically set a Network Profile" +driver.executeScript("sauce: network-profile", "4G-fast"); +``` + +To disable network throttling, use the predefined network profile `no-throttling`: + +```java +driver.executeScript("sauce: network-profile", "no-throttling"); +``` + +## Live Testing +Apply network throttling dynamically to your manual Live tests by selecting a predefined profile or by providing network conditions. + +1. In the live test window, in the left toolbar, click **Throttle Network** to open the network throttling tool. + + + +2. Select a predefined profile from the dropdown to start the network throttling. + + + +An active network throttling is indicated by the **pulsing red dot** on the top left of the **Throttle Network** tool. + + + +3. Click on the **pulsing red dot** to **pause** the network throttling. A paused throttling is indicated by the **pause icon**. + + + ## Upcoming -* Apply network throttling to your manual Live tests -* Change your desired network conditions dynamically any time during your automated Appium test -* Apply network throttling to your Espresso and XCUITest tests +* Apply network throttling to your native Espresso and XCUITest tests + ## Limitations :::note Limitations diff --git a/static/img/mobile-apps/throttle-network-1.png b/static/img/mobile-apps/throttle-network-1.png new file mode 100644 index 0000000000..b4ad73bac9 Binary files /dev/null and b/static/img/mobile-apps/throttle-network-1.png differ diff --git a/static/img/mobile-apps/throttle-network-2.png b/static/img/mobile-apps/throttle-network-2.png new file mode 100644 index 0000000000..ca4771a762 Binary files /dev/null and b/static/img/mobile-apps/throttle-network-2.png differ diff --git a/static/img/mobile-apps/throttle-network-3.png b/static/img/mobile-apps/throttle-network-3.png new file mode 100644 index 0000000000..f1e464b19f Binary files /dev/null and b/static/img/mobile-apps/throttle-network-3.png differ diff --git a/static/img/mobile-apps/throttle-network-4.png b/static/img/mobile-apps/throttle-network-4.png new file mode 100644 index 0000000000..8f94cfed9d Binary files /dev/null and b/static/img/mobile-apps/throttle-network-4.png differ