Class SelenideProxyServer


  • public class SelenideProxyServer
    extends java.lang.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, org.openqa.selenium.Proxy outsideProxy)
      Create server Note that server is not started nor activated yet.
      protected SelenideProxyServer​(Config config, org.openqa.selenium.Proxy outsideProxy, InetAddressResolver inetAddressResolver, net.lightbody.bmp.BrowserMobProxy proxy)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addRequestFilter​(java.lang.String name, net.lightbody.bmp.filters.RequestFilter requestFilter)
      Add a custom request filter which allows to track/modify all requests from browser to server
      void addResponseFilter​(java.lang.String name, net.lightbody.bmp.filters.ResponseFilter responseFilter)
      Add a custom response filter which allows to track/modify all server responses to browser
      org.openqa.selenium.Proxy createSeleniumProxy()
      Converts this proxy to a "selenium" proxy that can be used by webdriver
      net.lightbody.bmp.BrowserMobProxy getProxy()
      Method return current instance of browser mob proxy
      boolean isStarted()  
      <T extends net.lightbody.bmp.filters.RequestFilter>
      T
      requestFilter​(java.lang.String name)
      Get request filter by name
      <T extends net.lightbody.bmp.filters.ResponseFilter>
      T
      responseFilter​(java.lang.String name)
      Get response filter by name By default, the only one filter "download" is available.
      void shutdown()
      Stop the server
      void start()
      Start the server It automatically adds one response filter "download" that can intercept downloaded files.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • SelenideProxyServer

        public SelenideProxyServer​(Config config,
                                   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,
                                      org.openqa.selenium.Proxy outsideProxy,
                                      InetAddressResolver inetAddressResolver,
                                      net.lightbody.bmp.BrowserMobProxy proxy)
    • Method Detail

      • 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​(java.lang.String name,
                                     net.lightbody.bmp.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​(java.lang.String name,
                                      net.lightbody.bmp.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
      • createSeleniumProxy

        public org.openqa.selenium.Proxy createSeleniumProxy()
        Converts this proxy to a "selenium" proxy that can be used by webdriver
      • shutdown

        public void shutdown()
        Stop the server
      • getProxy

        public net.lightbody.bmp.BrowserMobProxy getProxy()
        Method return current instance of browser mob proxy
        Returns:
        browser mob proxy instance
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • requestFilter

        public <T extends net.lightbody.bmp.filters.RequestFilter> T requestFilter​(java.lang.String name)
        Get request filter by name
      • responseFilter

        public <T extends net.lightbody.bmp.filters.ResponseFilter> T responseFilter​(java.lang.String name)
        Get response filter by name By default, the only one filter "download" is available.