我想启动浏览器(FF,CHROME)以测试禁用的cookie,我尝试这样做:
service = new ChromeDriverService.Builder() .usingDriverExecutable(new File("src/test/resources/chromedriver")) .usingAnyFreePort().build(); try { service.start(); } catch (IOException e1) { e1.printStackTrace(); } DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability("disable-restore-session-state", true); driver = new ChromeDriver(service, capabilities);
但这不行…
我刚刚获得了Firefox的解决方案:
FirefoxProfile profile = new ProfilesIni().getProfile("default"); profile.setPreference("network.cookie.cookieBehavior", 2); driver = new FirefoxDriver(profile);
但我不知道如何使用Chrome进行管理。