0

I am trying to capture https traffic using selenium but is not able to capture it. Http traffic is captured correctly but having issue with https traffic. Get the same message on both chrome and firefox

'Oops.

Something went wrong.

Firefox can't load this page for some reason.'

package com.quadanalytix.selenium;

import org.browsermob.proxy.ProxyServer;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

public class Test2 {

    public static void main(String[] args) throws Exception {
        ProxyServer server = new ProxyServer(4446);
        server.start();

        // get the Selenium proxy object
        Proxy proxy = new Proxy();
        proxy.setSslProxy("localhost:4446");
        proxy.setHttpProxy("localhost:4446");

        //captures the moouse movements and navigations
        server.setCaptureHeaders(true);
        server.setCaptureContent(true);


        // configure it as a desired capability
        DesiredCapabilities capabilities = DesiredCapabilities.chrome();
        capabilities.setCapability(CapabilityType.PROXY, proxy);
        System.setProperty("webdriver.chrome.driver", "/Users/tarunaggarwal/Desktop/Selenium/ChromeDriver");
        // start the browser up
        WebDriver driver = new ChromeDriver(capabilities);


        server.newHar("gmail");
        driver.get("https://www.gmail.com/");

        server.stop();
        driver.quit();

    }

}
Mamta Garg
  • 141
  • 1
  • 1
  • 6
  • I got this same error when I had added custom code to net.lightbody.bmp.proxy.http.BrowserMobHttpClient.execute() that was throwing an uncaught exception. You're obviously not running my custom code, but this might be a clue as to where the problem is. – David Sickmiller Oct 14 '14 at 20:12

1 Answers1

0

Why are you creating a new Java proxy object instead of the follwing?

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(CapabilityType.PROXY, server.seleniumProxy());

Can you try the following with chrome:

ChromeOptions options = new ChromeOptions()
options.addArguments("--proxy-server=localhost:4446")
driver = new ChromeDriver(options)
Scott
  • 9,106
  • 6
  • 50
  • 79
  • I am using 2.0-beta-8 . Tried with both 7 and 8 but to no benefit OS :- MAC Selenium :- 2.42 Version – Mamta Garg Aug 19 '14 at 14:22
  • I tried this first , but it did not work . Output of both the instances is same – Mamta Garg Aug 20 '14 at 06:53
  • If that doesn't work, you might want to roll back your version of Selenium, granted that will likely cause issues with FF. All in all, we all might need to find another proxy solution (or assist in the redesign) until BMP receives it's major update. – Scott Aug 20 '14 at 20:38