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();

    }

}
4

1 回答 1

0

为什么要创建一个新的 Java 代理对象而不是下面的?

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

您可以使用 chrome 尝试以下操作:

ChromeOptions options = new ChromeOptions()
options.addArguments("--proxy-server=localhost:4446")
driver = new ChromeDriver(options)
于 2014-08-19T13:11:02.137 回答