当我同时使用“ --headless”参数和“ --ignore-certificate-errors”时,我的测试运行缓慢。但是由于SSL错误,我需要使用“ --ignore-certificate-errors”。 我正在使用ChromeDriver 84.0.4147.30。
这是我的设置。
@BeforeSuite
public static void setup() {
System.setProperty("webdriver.chrome.driver", "drivers/chromedriver.exe");
proxy = new BrowserMobProxyServer();
proxy.start(0);
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
ChromeOptions options = new ChromeOptions();
options.setCapability(CapabilityType.PROXY, seleniumProxy);
options.addArguments("--window-size=1920,1080","--ignore-certificate-errors");
driver = new ChromeDriver(options);
proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT,CaptureType.RESPONSE_CONTENT,CaptureType.REQUEST_HEADERS);
proxy.newHar("first");
driver.get("https://here is hiden url");
har = proxy.getHar();
}
必要时还有pom依赖项
<dependencies>
<!-- https://mvnrepository.com/artifact/com.codeborne/selenide -->
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>selenide</artifactId>
<version>5.13.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.3.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/net.lightbody.bmp/browsermob-proxy -->
<dependency>
<groupId>net.lightbody.bmp</groupId>
<artifactId>browsermob-core</artifactId>
<version>2.1.5</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.30</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
</dependencies>
10秒无--headless
无头30秒
有什么办法可以解决此问题?