org.openqa.selenium.remote.internal.ApacheHttpClient is deprecated in Selenium 3.14.0 - What should be used instead?

99封情书 提交于 2019-12-10 03:04:12

问题


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 HttpClient implementation details were out of HttpCommandExecutor right from Selenium v2.45.0.
    • With the availability of Selenium v3.11, Selenium Grid was switched to use OkHttp rather than the Apache HttpClient.
    • Further with the release of Selenium v3.141.0, Apache HttpClient was removed from selenium-server-standalone which drastically reduced the size of selenium server distribution package.
    • Even the apache-backed httpclient was also removed.


来源:https://stackoverflow.com/questions/54908461/org-openqa-selenium-remote-internal-apachehttpclient-is-deprecated-in-selenium-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!