Package com.codeborne.selenide.proxy
Class SelenideProxyServer
java.lang.Object
com.codeborne.selenide.proxy.SelenideProxyServer
Selenide own proxy server to intercept server responses
It holds map of request and response filters by name.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionSelenideProxyServer(Config config, @Nullable org.openqa.selenium.Proxy outsideProxy) Create server Note that server is not started nor activated yet.protectedSelenideProxyServer(Config config, @Nullable org.openqa.selenium.Proxy outsideProxy, com.browserup.bup.BrowserUpProxy proxy) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRequestFilter(String name, com.browserup.bup.filters.RequestFilter requestFilter) Add a custom request filter which allows to track/modify all requests from browser to servervoidaddResponseFilter(String name, com.browserup.bup.filters.ResponseFilter responseFilter) Add a custom response filter which allows to track/modify all server responses to browsercom.browserup.bup.BrowserUpProxygetProxy()Method return current instance of browser up proxy@Nullable org.openqa.selenium.ProxyReturns a "selenium" proxy that can be used by webdriver.boolean@Nullable com.browserup.bup.filters.RequestFilterremoveRequestFilter(String name) Remove (previously added) request filter by name@Nullable com.browserup.bup.filters.ResponseFilterremoveResponseFilter(String name) Remove (previously added) response filter by name<T extends com.browserup.bup.filters.RequestFilter>
@Nullable TrequestFilter(String name) Get request filter by name<T extends com.browserup.bup.filters.ResponseFilter>
@Nullable TresponseFilter(String name) Get response filter by namevoidshutdown()Stop the servervoidstart()Start the servertoString()
-
Constructor Details
-
SelenideProxyServer
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 serverIt automatically adds one response filter "download" that can intercept downloaded files.
-
isStarted
public boolean isStarted() -
addRequestFilter
Add a custom request filter which allows to track/modify all requests from browser to server- Parameters:
name- unique name of filterrequestFilter- 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 methodaddRequestFilter(String, RequestFilter)- Returns:
- the removed filter, or
nullif such filter hadn't been added - Since:
- 7.5.0
-
addResponseFilter
Add a custom response filter which allows to track/modify all server responses to browser- Parameters:
name- unique name of filterresponseFilter- 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 methodaddResponseFilter(String, ResponseFilter)- Returns:
- the removed filter, or
nullif 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
-
requestFilter
Get request filter by name -
responseFilter
Get response filter by nameBy default, the only one filter "download" is available.
-
responseMocker
-