Search in sources :

Example 1 with FileServer

use of com.github.timurstrekalov.saga.core.FileServer in project saga by timurstrekalov.

the class InstrumentingProxyServerIT method setUp.

@Before
public void setUp() throws Exception {
    final InstanceFieldPerPropertyConfig config = new InstanceFieldPerPropertyConfig();
    proxyServer = new InstrumentingProxyServer(new HtmlUnitBasedScriptInstrumenter(config));
    fileServer = new FileServer(new File(getClass().getResource("/tests").toURI()).getAbsolutePath());
    proxyServerPort = proxyServer.start();
    fileServerPort = fileServer.start();
    final String proxyUrl = "localhost:" + proxyServerPort;
    final Proxy proxy = new Proxy().setProxyType(Proxy.ProxyType.MANUAL).setHttpProxy(proxyUrl).setSslProxy(proxyUrl);
    final DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    desiredCapabilities.setCapability(CapabilityType.PROXY, proxy);
    desiredCapabilities.setCapability(CapabilityType.SUPPORTS_JAVASCRIPT, true);
    desiredCapabilities.setBrowserName(BrowserType.FIREFOX);
    driver = new HtmlUnitDriver(desiredCapabilities) {

        @Override
        protected WebClient newWebClient(final BrowserVersion version) {
            config.setBrowserVersion(version);
            return WebClientFactory.newInstance(config);
        }
    };
}
Also used : Proxy(org.openqa.selenium.Proxy) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) InstanceFieldPerPropertyConfig(com.github.timurstrekalov.saga.core.cfg.InstanceFieldPerPropertyConfig) InstrumentingProxyServer(com.github.timurstrekalov.saga.core.server.InstrumentingProxyServer) File(java.io.File) BrowserVersion(com.gargoylesoftware.htmlunit.BrowserVersion) WebClient(com.gargoylesoftware.htmlunit.WebClient) FileServer(com.github.timurstrekalov.saga.core.FileServer) HtmlUnitDriver(org.openqa.selenium.htmlunit.HtmlUnitDriver) Before(org.junit.Before)

Aggregations

BrowserVersion (com.gargoylesoftware.htmlunit.BrowserVersion)1 WebClient (com.gargoylesoftware.htmlunit.WebClient)1 FileServer (com.github.timurstrekalov.saga.core.FileServer)1 InstanceFieldPerPropertyConfig (com.github.timurstrekalov.saga.core.cfg.InstanceFieldPerPropertyConfig)1 InstrumentingProxyServer (com.github.timurstrekalov.saga.core.server.InstrumentingProxyServer)1 File (java.io.File)1 Before (org.junit.Before)1 Proxy (org.openqa.selenium.Proxy)1 HtmlUnitDriver (org.openqa.selenium.htmlunit.HtmlUnitDriver)1 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)1