使用Java运行一些Selenium WebDriver测试之前,请清除缓存 [英] Clear cache before running some Selenium WebDriver tests using Java
本文介绍了使用Java运行一些Selenium WebDriver测试之前,请清除缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用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.
推荐答案
这是我在Python中使用的方法:
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)
您可以尝试将它们转换为Java.希望这会有所帮助! :)
You can try converting these into Java. Hope this will help! :)
这篇关于使用Java运行一些Selenium WebDriver测试之前,请清除缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文