public class Test {
public static void main(String[] args) throws Exception{
String driverGoogleChromePath = "D:\\Project Doc\\Jar\\selenium\\chromedriver_win32\\chromedriver.exe";
String refererurl = "http://www.iteye.com/";
String hostAndPort = "112.91.159.66:3128";
int port = 3128;
//String host = "112.91.159.66";
System.setProperty("webdriver.chrome.driver",driverGoogleChromePath);
//start the proxy
BrowserMobProxy proxy = new BrowserMobProxyServer();
Map<String, String> headers = new HashMap<String, String>();
headers.put("Referer",refererurl);
proxy.addHeaders(headers);
proxy.start(port);
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
seleniumProxy.setHttpProxy(hostAndPort)
.setSslProxy(hostAndPort)
.setFtpProxy(hostAndPort);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
ChromeOptions option = new ChromeOptions().merge(capabilities);
WebDriver driver = new ChromeDriver(option);
Thread.sleep(3000);
driver.get("http://www.java1234.com/");
proxy.stop();
//driver.close();
}
This is my java code, I have set the referer to use the .addHeaders, but when I run it, the browser didn't show the referer, why, how to do show this ?
selenium: selenium-server-standalone-3.141.5.jar browser: browsermob-dist-2.1.4.jar