问题
I am currently using Selenium 3.14.0 library in which org.openqa.selenium.remote.internal.ApacheHttpClient is deprecated with no other information. Which should be used instead?
The class is already removed in the next version, 3.141.59.
I am using it with EdgeDriver Service like following:
final int connectionTimeout = 2 * 60 * 1000;
final int socketTimeout = 10 * 60 * 1000; // 10 minute timeout
final ApacheHttpClient.Factory clientFactory = new ApacheHttpClient.Factory(
new HttpClientFactory(connectionTimeout, socketTimeout));
...
edgeDriverService = new EdgeDriverService.Builder()
.usingDriverExecutable(edgeDriver)
.usingAnyFreePort()
.build();
edgeDriverService.start();
HttpCommandExecutor executor = new HttpCommandExecutor(
new HashMap<>(), edgeDriverService.getUrl(), clientFactory);
WebDriver driver = new RemoteWebDriver(executor, new EdgeOptions());
回答1:
The HTTP client was switched to okhttp: http://square.github.io/okhttp/
This is mentioned in the Selenium Java CHANGELOG of version 3.11.0 and also you can see it in the source code.
回答2:
A couple of facts:
- The Java RemoteWebDriver client uses a CommandExecutor to send commands to a RemoteWebDriver. By default, RemoteWebDriver uses an HttpCommandExecutor which uses the Apache HttpClient library to send the commands.
- As per the CHANGELOG
- The
HttpClientimplementation details were out ofHttpCommandExecutorright from Selenium v2.45.0. - With the availability of Selenium v3.11, Selenium Grid was switched to use
OkHttprather than theApache HttpClient. - Further with the release of Selenium v3.141.0,
Apache HttpClientwas removed fromselenium-server-standalonewhich drastically reduced the size of selenium server distribution package. - Even the
apache-backed httpclientwas also removed.
- The
来源:https://stackoverflow.com/questions/54908461/org-openqa-selenium-remote-internal-apachehttpclient-is-deprecated-in-selenium-3