Class BrowserNetworkProfileManager

java.lang.Object
com.shaft.gui.browser.internal.BrowserNetworkProfileManager

public final class BrowserNetworkProfileManager extends Object
Applies browser network profiles through Selenium DevTools when the active driver supports them.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    blockResources(org.openqa.selenium.WebDriver driver, String... urlPatterns)
    Blocks browser requests whose URLs match the supplied DevTools patterns.
    static boolean
    goOffline(org.openqa.selenium.WebDriver driver)
    Enables offline browser networking.
    static boolean
    restore(org.openqa.selenium.WebDriver driver)
    Restores default browser networking and clears blocked URL patterns.
    static boolean
    throttle(org.openqa.selenium.WebDriver driver, long latencyMs, long downloadKbps, long uploadKbps)
    Applies fixed latency and throughput limits.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • goOffline

      public static boolean goOffline(org.openqa.selenium.WebDriver driver)
      Enables offline browser networking.
      Parameters:
      driver - active WebDriver
      Returns:
      true when the profile was applied
    • restore

      public static boolean restore(org.openqa.selenium.WebDriver driver)
      Restores default browser networking and clears blocked URL patterns.
      Parameters:
      driver - active WebDriver
      Returns:
      true when the profile was restored
    • throttle

      public static boolean throttle(org.openqa.selenium.WebDriver driver, long latencyMs, long downloadKbps, long uploadKbps)
      Applies fixed latency and throughput limits.
      Parameters:
      driver - active WebDriver
      latencyMs - network latency in milliseconds
      downloadKbps - download throughput in kilobits per second
      uploadKbps - upload throughput in kilobits per second
      Returns:
      true when the profile was applied
    • blockResources

      public static boolean blockResources(org.openqa.selenium.WebDriver driver, String... urlPatterns)
      Blocks browser requests whose URLs match the supplied DevTools patterns.
      Parameters:
      driver - active WebDriver
      urlPatterns - DevTools URL patterns
      Returns:
      true when the patterns were applied