Fail to set the --host-resolver-rules option for Chrome

547 views
Skip to first unread message

Zhenyu Zhou

unread,
Jun 5, 2015, 7:43:38 PM6/5/15
to seleniu...@googlegroups.com
Hi all,

I'm trying to build a website mirror on my server so that I need to set the host resolver rules by myself. In terminal, I can use this command to redirect it successfully (the chrome knows to load Google from my server):

./chrome --no-sandbox --enable-quic --origin-to-force-quic-on=www.google.com:80 --host-resolver-rules="MAP www.google.com 152.3.144.156" http://www.google.com

However, when it comes to Selenium, Chrome remains to retrieve the original Google homepage rather than go through my server. Here is my code (in JAVA):

System.setProperty("webdriver.chrome.driver", "/home/zzy/Downloads/chromedriver");
ChromeOptions options = new ChromeOptions();
options.setBinary("/home/zzy/quic/src/out/Debug/chrome");
options.addArguments("no-sandbox");
options.addArguments("--enable-quic");
options.addArguments("--origin-to-force-quic-on='www.google.com:80'");
options.addArguments("--whitelisted-ips='152.3.144.156'");
options.addArguments("--host-resolver-rules='MAP www.google.com 152.3.144.156'"); 
        // also not work
// options.addArguments("--no-sandbox", "--enable-quic", "--origin-to-force-quic-on='www.google.com:80'", "--host-resolver-rules='MAP * 0.0.0.0'");
ChromeDriver driver = new ChromeDriver(options);
                // Chrome will go to Google homepage directly without redirecting
driver.get("http://www.google.com");

Does anyone have insight how to make the option work? Any suggestions are appreciable.

Many thanks!

Zhenyu

David Bau

unread,
Dec 31, 2016, 12:51:16 AM12/31/16
to Selenium Users
I just figured this one out - the chromedriver does not handle quoted option values; so try removing the quotes, something like this:

options.addArguments("--host-resolver-rules=MAP www.google.com 152.3.144.156"); 

David
Reply all
Reply to author
Forward
0 new messages