2013-12-12 4 views
0

Мне нужно отключить файлы cookie в chrome и IE с помощью Webdriver.отключение файлов cookie в chrome и IE с помощью Webdriver

для хрома - Я пытаюсь следующий код не успеш-

DesiredCapabilities capabilities = DesiredCapabilities.chrome(); 
capabilities.setCapability(ChromeOptions.CAPABILITY, options); 
capabilities.setCapability("chrome.switches", Arrays.asList("--disable-local-storage")); 

для IE - нет идей

Однако я был в состоянии отключить для Firefox с помощью следующего code-

ProfilesIni profile = new ProfilesIni(); 
FirefoxProfile ffprofile = profile.getProfile(allElements[1]); 

ffprofile.setPreference("network.cookie.cookieBehavior", 2); 
+0

все еще ищет решение для IE.Any идеи? – user3090371

ответ

2

Следующие файлы запрещены в Chrome:

WebDriver driver; 
ChromeOptions options = new ChromeOptions(); 
Map<String, Object> prefs = new HashMap<String, Object>(); 
prefs.put("profile.default_content_settings.cookies", 2); 
options.setExperimentalOption("prefs", prefs); 
driver = new ChromeDriver(options); 
0

наконец-то получил решение для IE. Вы не можете сделать это с помощью WebDriver, но и необходимо для редактирования реестра через Java

отключить куки

String command = "REG ADD \"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\  \" /v 1A10 /t REG_DWORD /d 0X3 /f"; 
Runtime.getRuntime().exec(command); 

, чтобы включить куки

String command = "REG ADD \"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\  \" /v 1A10 /t REG_DWORD /d 0X1 /f"; 
Runtime.getRuntime().exec(command); 
Смежные вопросы