This question already has answers here:
org.openqa.selenium.remote.internal.ApacheHttpClient is deprecated in Selenium 3.14.0 - What should be used instead?
                                
                                    (2个答案)
                                
                        
                                2个月前关闭。
            
                    
我有如下代码

RemoteWebDriver driver = new RemoteWebDriver(new HttpCommandExecutor(new HashMap<String, CommandInfo>(),
                new URL(URL), new Factory() {
                    private HttpClientBuilder builder;
                    {
                        builder = HttpClientBuilder.create();
                        HttpHost proxy = new HttpHost(proxy,proxyport);
                        System.out.println(proxy);
                        builder.setProxy(proxy);
                        System.out.println(builder);

                    }

                    @Override
                    public HttpClient createClient(URL url) {
                        return new ApacheHttpClient(builder.build(), url);
                    }


但由于不赞成使用ApacheHttpClient类,因此在上述代码中可以使用ApacheHttpClient类的替代方法

最佳答案

您可以使用HttpClient代替ApacheHttpClient

07-28 14:09