【发布时间】:2020-12-20 00:49:50
【问题描述】:
我正在使用 Selenium 和 ChromeDriver 编写一个测试来模拟网络连接丢失。
this.chromeDriver.setNetworkConnection(NetworkConnection.ConnectionType.AIRPLANE_MODE);
//wait and do actions
this.chromeDriver.setNetworkConnection(NetworkConnection.ConnectionType.WIFI);
//asserts
我的测试在一个容器中运行,目前我正在将一个 WebDriver 的注入实例转换为我知道的 Chrome 为 this.chromeDriver = (ChromeDriver)this.webDriver;
在网上看,我看不到通过 WebDriver 实例关闭网络连接的方法,我想避免仅为测试而在主机级别关闭/打开。有没有更好的方法在 3.6 中使用 Selenium 实现网络模拟?
【问题讨论】:
标签: java selenium selenium-webdriver