Class SelenideProxyServer

java.lang.Object
com.codeborne.selenide.proxy.SelenideProxyServer

public class SelenideProxyServer extends Object
Selenide own proxy server to intercept server responses

It holds map of request and response filters by name.

  • Constructor Details

    • SelenideProxyServer

      public SelenideProxyServer(Config config, @Nullable org.openqa.selenium.Proxy outsideProxy)
      Create server Note that server is not started nor activated yet.
      Parameters:
      outsideProxy - another proxy server used by test author for his own need (can be null)
    • SelenideProxyServer

      protected SelenideProxyServer(Config config, @Nullable org.openqa.selenium.Proxy outsideProxy, com.browserup.bup.BrowserUpProxy proxy)
  • Method Details

    • getSeleniumProxy

      public @Nullable org.openqa.selenium.Proxy getSeleniumProxy()
      Returns a "selenium" proxy that can be used by webdriver. Available after SelenideProxyServer.start() and SelenideProxyServer.createSeleniumProxy() call.
    • start

      public void start()
      Start the server

      It automatically adds one response filter "download" that can intercept downloaded files.

    • isStarted

      public boolean isStarted()
    • addRequestFilter

      public void addRequestFilter(String name, com.browserup.bup.filters.RequestFilter requestFilter)
      Add a custom request filter which allows to track/modify all requests from browser to server
      Parameters:
      name - unique name of filter
      requestFilter - the filter
    • removeRequestFilter

      @CanIgnoreReturnValue public @Nullable com.browserup.bup.filters.RequestFilter removeRequestFilter(String name)
      Remove (previously added) request filter by name
      Parameters:
      name - Name of the filter used in method addRequestFilter(String, RequestFilter)
      Returns:
      the removed filter, or null if such filter hadn't been added
      Since:
      7.5.0
    • addResponseFilter

      public void addResponseFilter(String name, com.browserup.bup.filters.ResponseFilter responseFilter)
      Add a custom response filter which allows to track/modify all server responses to browser
      Parameters:
      name - unique name of filter
      responseFilter - the filter
    • removeResponseFilter

      @CanIgnoreReturnValue public @Nullable com.browserup.bup.filters.ResponseFilter removeResponseFilter(String name)
      Remove (previously added) response filter by name
      Parameters:
      name - Name of the filter used in method addResponseFilter(String, ResponseFilter)
      Returns:
      the removed filter, or null if such filter hadn't been added
      Since:
      7.5.0
    • shutdown

      public void shutdown()
      Stop the server
    • getProxy

      public com.browserup.bup.BrowserUpProxy getProxy()
      Method return current instance of browser up proxy
      Returns:
      browser up proxy instance
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • requestFilters

      public Map<String,com.browserup.bup.filters.RequestFilter> requestFilters()
      Get all request filters
    • requestFilterNames

      public List<String> requestFilterNames()
      Get all request filter names
    • requestFilter

      public <T extends com.browserup.bup.filters.RequestFilter> @Nullable T requestFilter(String name)
      Get request filter by name
    • responseFilters

      public Map<String,com.browserup.bup.filters.ResponseFilter> responseFilters()
      Get all response filters
    • responseFilterNames

      public List<String> responseFilterNames()
      Get all response filter names
    • responseFilter

      public <T extends com.browserup.bup.filters.ResponseFilter> @Nullable T responseFilter(String name)
      Get response filter by name

      By default, the only one filter "download" is available.

    • responseMocker

      public MockResponseFilter responseMocker()