Skip to content

Commit cf02da5

Browse files
committed
#1433 fix overriding default timeout for Selenium http client
it was broken because `ClientConfig.readTimeout(n)` is not a setter anymore, but it returns a new instance.
1 parent 7070ae6 commit cf02da5

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 6.3.0
44
* add support for BEARER token authentication
55
* upgrade to Selenium 4.1.2
6+
* #1433 fix overriding default timeout for Selenium http client
67

78
## 6.2.1 (released 19.01.2022)
89
* #1702 Ignore whitespaces for filename in Content-Disposition header -- thanks Yevgeniy Mikhailov for PR #1702
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.codeborne.selenide.webdriver;
2+
3+
import com.google.auto.service.AutoService;
4+
import org.openqa.selenium.remote.http.ClientConfig;
5+
import org.openqa.selenium.remote.http.HttpClient;
6+
import org.openqa.selenium.remote.http.HttpClientName;
7+
import org.openqa.selenium.remote.http.netty.NettyClient;
8+
9+
import static com.codeborne.selenide.webdriver.HttpClientTimeouts.defaultReadTimeout;
10+
11+
@AutoService(HttpClient.Factory.class)
12+
@HttpClientName("selenide-netty-client-factory")
13+
public class SelenideNettyClientFactory extends NettyClient.Factory {
14+
15+
@Override
16+
public HttpClient createClient(ClientConfig config) {
17+
ClientConfig configWithShorterTimeout = config.readTimeout(defaultReadTimeout);
18+
return super.createClient(configWithShorterTimeout);
19+
}
20+
}

src/main/java/com/codeborne/selenide/webdriver/WebDriverFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ private WebDriver createWebDriverInstance(Config config, Browser browser,
105105
if (config.driverManagerEnabled()) {
106106
webdriverFactory.setupWebdriverBinary();
107107
}
108+
System.setProperty("webdriver.http.factory", "selenide-netty-client-factory");
108109
WebDriver webDriver = webdriverFactory.create(config, browser, proxy, browserDownloadsFolder);
109110
httpClientTimeouts.setup(webDriver);
110111
return webDriver;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
com.codeborne.selenide.webdriver.SelenideNettyClientFactory

0 commit comments

Comments
 (0)