How to clear browser cache automatically in Selenium WebDriver?

后端 未结 5 1355
别那么骄傲
别那么骄傲 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:05

    Using java you can achieve that:

    protected void deleteCookie(String cookieName) {    
        String cookieDomain = CTPropertiesManager.getProperty("site.properties", "site.cookie.domain");
        try {
            //get all cookies
            Cookie cookies[] = request.getCookies();
            Cookie ctCookie=null;
            if (cookies !=null) {
                for(int i=0; i

    For deleting cache You can create one bat file which clear your browser or application cache before test start. after creating bat file just call in your code before test start.

提交回复
热议问题