我正在使用Java编程语言进行Selenium WebDriver自动化。在我的测试套件中,该套件一次启动浏览器窗口并执行所有测试。我想在运行某些测试之前清除浏览器缓存,而无需重新启动浏览器。有没有可以达到目的的命令/功能?谢谢。
我正在尝试清除Chrome浏览器(Selenium中的Webdriver)中的缓存和cookie,但是找不到针对chrome驱动程序的任何解决方案。如何清除Python中的缓存和cookie?谢谢!
python selenium webdriver selenium-chromedriver selenium-webdriver
我想ChromeDriverService与xvfb 中运行的浏览器chromeOptions合并。DesiredCapabilities
下面是ChromeDriverService我之前在没有硒网格的情况下使用的代码的一部分。
String NodeChromeIncognito = "http://localhost:5558/wd/hub"
ChromeDriverService chromeDriverService = new ChromeDriverService.Builder()
.usingDriverExecutable(new File("driver_linux/chromedriver"))
.usingAnyFreePort()
.withEnvironment(ImmutableMap.of("DISPLAY", ":1")).build();
chromeDriverService.start();
// commented because using RemoteWebDriver
// driver = new ChromeDriver(chromeDriverService);
Run Code Online (Sandbox Code Playgroud)
下面是 RemoteWebDriver 的部分代码,我将与ChromeDriverService.
DesiredCapabilities cap = null;
String NodeChromeIncognito = "http://localhost:5558/wd/hub";
String NodeChrome = "http://localhost:5557/wd/hub";
String NodeFirefox = "http://localhost:5556/wd/hub";
if (browserName.equals("chrome")) {
cap = DesiredCapabilities.chrome();
cap.setBrowserName("chrome");
driver = new RemoteWebDriver(new URL(NodeChrome), cap);
} else if (browserName.equals("firefox")) {
System.setProperty("webdriver.gecko.driver", "driver_linux/geckodriver");
cap = DesiredCapabilities.firefox();
cap.setCapability("marionette", …Run Code Online (Sandbox Code Playgroud)