java清理web缓存,使用Java运行某些Selenium WebDriver测试之前,请清除缓存

I am working on Selenium WebDriver automation in java programming language. In my test suite that initiates the browser window once and perform all the tests. I want to clear the browser cache before running some tests without restarting the browser. Is there any command/function, that can achieve the purpose? Thanks.

解决方案

This is what I use in Python:

from selenium import webdriver

from selenium.webdriver.common.keys import Keys

driver = webdriver.Chrome()

driver.get('chrome://settings/clearBrowserData')

driver.find_element_by_xpath('//settings-ui').send_keys(Keys.ENTER)

You can try converting these into Java. Hope this will help! :)

你可能感兴趣的:(java清理web缓存)