Search in sources :

Example 1 with Config

use of io.github.bonigarcia.wdm.Config in project webdrivermanager by bonigarcia.

the class ProxyTest method getProxy.

private Optional<Proxy> getProxy(WebDriverManager browserManager) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, MalformedURLException {
    Field httpClientField = WebDriverManager.class.getDeclaredField("httpClient");
    httpClientField.setAccessible(true);
    httpClientField.set(browserManager, new HttpClient());
    Field configField = WebDriverManager.class.getDeclaredField("config");
    configField.setAccessible(true);
    Config config = (Config) configField.get(browserManager);
    String proxy = config.getProxy();
    HttpClient wdmHttpClient = (HttpClient) httpClientField.get(browserManager);
    return wdmHttpClient.createProxy(proxy);
}
Also used : Field(java.lang.reflect.Field) Config(io.github.bonigarcia.wdm.Config) HttpClient(io.github.bonigarcia.wdm.HttpClient) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient)

Example 2 with Config

use of io.github.bonigarcia.wdm.Config in project selenium_java by sergueik.

the class ProxyTest method getProxy.

private Optional<Proxy> getProxy(WebDriverManager browserManager) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, MalformedURLException {
    Field httpClientField = WebDriverManager.class.getDeclaredField("httpClient");
    httpClientField.setAccessible(true);
    httpClientField.set(browserManager, new HttpClient());
    Field configField = WebDriverManager.class.getDeclaredField("config");
    configField.setAccessible(true);
    Config config = (Config) configField.get(browserManager);
    String proxy = config.getProxy();
    HttpClient wdmHttpClient = (HttpClient) httpClientField.get(browserManager);
    return wdmHttpClient.createProxy(proxy);
}
Also used : Field(java.lang.reflect.Field) Config(io.github.bonigarcia.wdm.Config) HttpClient(io.github.bonigarcia.wdm.HttpClient) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient)

Aggregations

Config (io.github.bonigarcia.wdm.Config)2 HttpClient (io.github.bonigarcia.wdm.HttpClient)2 Field (java.lang.reflect.Field)2 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)2