How to clear browser cache automatically in Selenium WebDriver?

后端 未结 5 1319
别那么骄傲
别那么骄傲 2021-01-17 17:30

How to clear browser cache before every test run? I tried with driver.manage().deleteAllCookies(); in setUp method after creating the driver instan

5条回答
  •  星月不相逢
    2021-01-17 18:08

    There is a driver capability you can set as follows:

    DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
    capabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
    

    It worked for me on IE11.

    Source: http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/ie/InternetExplorerDriver.html

提交回复
热议问题