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 Summary

    Constructors
    Modifier
    Constructor
    Description
     
    SelenideProxyServer(Config config, @Nullable org.openqa.selenium.Proxy outsideProxy)
    Create server Note that server is not started nor activated yet.
    protected
    SelenideProxyServer(Config config, @Nullable org.openqa.selenium.Proxy outsideProxy, com.browserup.bup.BrowserUpProxy proxy)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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
    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
    com.browserup.bup.BrowserUpProxy
    Method return current instance of browser up proxy
    @Nullable org.openqa.selenium.Proxy
    Returns a "selenium" proxy that can be used by webdriver.
    boolean
     
    <T extends com.browserup.bup.filters.RequestFilter>
    @Nullable T
    Get request filter by name
    <T extends com.browserup.bup.filters.ResponseFilter>
    @Nullable T
    Get response filter by name
     
    void
    Stop the server
    void
    Start the server
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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
    • 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
    • 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
    • requestFilter

      public <T extends com.browserup.bup.filters.RequestFilter> @Nullable T requestFilter(String name)
      Get request filter by name
    • 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()