8

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());
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
AndiCover
  • 1,724
  • 3
  • 17
  • 38

2 Answers2

11

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Corey Goldberg
  • 59,062
  • 28
  • 129
  • 143
0

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.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 9
    this is interesting background info, but not what the question asked.. the question asked what replaced Apache HttpClient – Corey Goldberg Feb 27 '19 at 19:37
  • Because of this my hub start command , which registers some custom servlets & uses custom jar (java -cp selenium-server-standalone-3.141.0.jar;mycustom.jar org.openqa.grid.selenium.GridLauncherV3 -role hub -port 4444 -servlets com.myservlet -timeout 1800) throws an error saying Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient . Are we supposed to include apache client jar file as an extra jar in above command ? – sjethvani Jun 14 '19 at 11:29