how to disable cookies using webdriver for Chrome and FireFox JAVA

前端 未结 6 1918
独厮守ぢ
独厮守ぢ 2020-12-01 16:55

I want launch browsers(FF, CHROME) for test with disabled cookies, I tried this:

           service =
                    new ChromeDriverService.Builder()
          


        
6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-01 17:06

    You can disable Chrome cookies as below:

    Map prefs = new HashMap();
    prefs.put("profile.default_content_settings.cookies", 2);
    ChromeOptions options = new ChromeOptions();
    options.setExperimentalOptions("prefs", prefs);
    driver = new ChromeDriver(options);
    

提交回复
热议问题