net.lightbody.bmp.client.ClientUtil Java Examples

The following examples show how to use net.lightbody.bmp.client.ClientUtil. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProxyBasedIT.java    From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License 6 votes vote down vote up
@Test
public void usingAProxyToTrackNetworkTrafficStep2() {
    BrowserMobProxy browserMobProxy = new BrowserMobProxyServer();
    browserMobProxy.start();
    Proxy seleniumProxyConfiguration = ClientUtil.createSeleniumProxy(browserMobProxy);

    FirefoxOptions firefoxOptions = new FirefoxOptions();
    firefoxOptions.setCapability(CapabilityType.PROXY, seleniumProxyConfiguration);
    driver = new FirefoxDriver(firefoxOptions);
    browserMobProxy.newHar();
    driver.get("https://www.google.co.uk");

    Har httpArchive = browserMobProxy.getHar();

    assertThat(getHTTPStatusCode("https://www.google.co.uk/", httpArchive))
            .isEqualTo(200);
}
 
Example #2
Source File: ProxyBasedIT.java    From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License 5 votes vote down vote up
@Test
public void usingAProxyToTrackNetworkTrafficStep1() {
    BrowserMobProxy browserMobProxy = new BrowserMobProxyServer();
    browserMobProxy.start();
    Proxy seleniumProxyConfiguration = ClientUtil.createSeleniumProxy(browserMobProxy);

    FirefoxOptions firefoxOptions = new FirefoxOptions();
    firefoxOptions.setCapability(CapabilityType.PROXY, seleniumProxyConfiguration);
    driver = new FirefoxDriver(firefoxOptions);
    browserMobProxy.newHar();
    driver.get("https://www.google.co.uk");
}
 
Example #3
Source File: CustomDriverProvider.java    From akita with Apache License 2.0 5 votes vote down vote up
/**
 * если установлен -Dproxy=true стартует прокси
 * har для прослушки указывается в application.properties
 * @param capabilities
 */
private void enableProxy(DesiredCapabilities capabilities) {
    proxy.setTrustAllServers(Boolean.valueOf(loadProperty(TRUST_ALL_SERVERS, "true")));
    proxy.start();

    Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);

    capabilities.setCapability(PROXY, seleniumProxy);
    capabilities.setCapability(ACCEPT_SSL_CERTS, Boolean.valueOf(loadProperty(ACCEPT_SSL_CERTS, "true")));
    capabilities.setCapability(SUPPORTS_JAVASCRIPT, Boolean.valueOf(loadProperty(SUPPORTS_JAVASCRIPT, "true")));

    proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.REQUEST_HEADERS, CaptureType.RESPONSE_CONTENT, CaptureType.RESPONSE_HEADERS);
    proxy.newHar(loadProperty(NEW_HAR));
}
 
Example #4
Source File: AbstractProxyTest.java    From bobcat with Apache License 2.0 5 votes vote down vote up
DesiredCapabilities proxyCapabilities(BrowserMobProxy browserMobProxy) {
  browserMobProxy.enableHarCaptureTypes(
      CaptureType.REQUEST_HEADERS,
      CaptureType.RESPONSE_HEADERS,
      CaptureType.REQUEST_CONTENT,
      CaptureType.RESPONSE_CONTENT);

  Proxy seleniumProxy = ClientUtil.createSeleniumProxy(browserMobProxy);
  DesiredCapabilities capabilities = new DesiredCapabilities();
  capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
  return capabilities;
}
 
Example #5
Source File: EnableProxy.java    From bobcat with Apache License 2.0 5 votes vote down vote up
private DesiredCapabilities enableProxy(Capabilities capabilities) {
  DesiredCapabilities caps = new DesiredCapabilities(capabilities);
  try {
    InetAddress proxyInetAddress = InetAddress.getByName(proxyIp);
    BrowserMobProxy browserMobProxy = proxyController.startProxyServer(proxyInetAddress);
    Proxy seleniumProxy = ClientUtil.createSeleniumProxy(browserMobProxy, proxyInetAddress);
    caps.setCapability(CapabilityType.PROXY, seleniumProxy);
  } catch (UnknownHostException e) {
    throw new IllegalStateException(e);
  }
  return caps;
}
 
Example #6
Source File: DefaultModule.java    From bromium with MIT License 4 votes vote down vote up
public Proxy createSeleniumProxy(BrowserMobProxy proxy) {
    return ClientUtil.createSeleniumProxy(proxy);
}