19
19
import org .apache .http .auth .AuthScope ;
20
20
import org .apache .http .auth .NTCredentials ;
21
21
import org .apache .http .auth .UsernamePasswordCredentials ;
22
- import org .apache .http .conn .params .ConnRoutePNames ;
23
- import org .apache .http .impl .client .DefaultHttpClient ;
24
- import org .apache .http .impl .conn .DefaultHttpRoutePlanner ;
22
+ import org .apache .http .client .CredentialsProvider ;
23
+ import org .apache .http .impl .client .BasicCredentialsProvider ;
24
+ import org .apache .http .impl .client .HttpClientBuilder ;
25
+ import org .apache .http .impl .conn .DefaultProxyRoutePlanner ;
25
26
import org .json .simple .JSONArray ;
26
27
import org .json .simple .JSONObject ;
27
28
import org .json .simple .JSONValue ;
39
40
import org .openqa .selenium .firefox .FirefoxProfile ;
40
41
import org .openqa .selenium .ie .InternetExplorerDriver ;
41
42
import org .openqa .selenium .ie .InternetExplorerOptions ;
42
- import org .openqa .selenium .opera .OperaDriver ;
43
- import org .openqa .selenium .opera .OperaOptions ;
44
43
import org .openqa .selenium .remote .Augmenter ;
45
44
import org .openqa .selenium .remote .DesiredCapabilities ;
46
45
import org .openqa .selenium .remote .HttpCommandExecutor ;
63
62
import com .machinepublishers .jbrowserdriver .JBrowserDriver ;
64
63
import com .machinepublishers .jbrowserdriver .Settings ;
65
64
66
- @ SuppressWarnings ("deprecation" )
67
65
@ RobotKeywords
68
66
public class BrowserManagement extends RunOnFailureKeywordsAdapter {
69
67
@@ -164,7 +162,6 @@ public void closeBrowser() {
164
162
"| Internet Explorer | internetexplorer, ie |\r \n " +
165
163
"| Edge | edge |\r \n " +
166
164
"| Safari | safari |\r \n " +
167
- "| Opera | opera |\r \n " +
168
165
"| Android | android |\r \n " +
169
166
"| Iphone | iphone |\r \n " +
170
167
"| JBrowser | jbrowser |\r \n " +
@@ -650,8 +647,6 @@ protected WebDriver createLocalWebDriver(String browserName, Capabilities desire
650
647
case "chromeheadless" :
651
648
case "googlechromeheadless" :
652
649
return new ChromeDriver ((ChromeOptions )desiredCapabilities );
653
- case "opera" :
654
- return new OperaDriver (new OperaOptions ().merge (desiredCapabilities ));
655
650
case "safari" :
656
651
return new SafariDriver (new SafariOptions ().merge (desiredCapabilities ));
657
652
case "jbrowser" :
@@ -717,9 +712,6 @@ protected Capabilities createCapabilities(String browserName, String desiredCapa
717
712
parseBrowserOptionsChrome (browserOptions , desiredCapabilities );
718
713
((ChromeOptions )desiredCapabilities ).setHeadless (true );
719
714
break ;
720
- case "opera" :
721
- desiredCapabilities = new OperaOptions ();
722
- break ;
723
715
case "safari" :
724
716
desiredCapabilities = new SafariOptions ();
725
717
break ;
@@ -856,25 +848,29 @@ protected void setRemoteWebDriverProxy(HttpCommandExecutor httpCommandExecutor)
856
848
className = "DefaultHttpClient" ;
857
849
Field field = HttpCommandExecutor .class .getDeclaredField (fieldName );
858
850
field .setAccessible (true );
859
- DefaultHttpClient client = (DefaultHttpClient ) field .get (httpCommandExecutor );
851
+ HttpClientBuilder clientBuilder = HttpClientBuilder .create ();
852
+ //DefaultHttpClient client = (DefaultHttpClient) field.get(httpCommandExecutor);
860
853
861
854
// set the credentials for the proxy
862
855
AuthScope authScope = new AuthScope (remoteWebDriverProxyHost , Integer .parseInt (remoteWebDriverProxyPort ));
856
+ CredentialsProvider credsProvider = new BasicCredentialsProvider ();
863
857
if (remoteWebDriverProxyDomain .length () == 0 ) {
864
858
// BASIC Authentication
865
- client . getCredentialsProvider () .setCredentials (authScope ,
859
+ credsProvider .setCredentials (authScope ,
866
860
new UsernamePasswordCredentials (remoteWebDriverProxyUser , remoteWebDriverProxyPassword ));
861
+ clientBuilder .setDefaultCredentialsProvider (credsProvider );
867
862
} else {
868
863
// NTLM Authentication
869
- client . getCredentialsProvider () .setCredentials (authScope , new NTCredentials (remoteWebDriverProxyUser ,
864
+ credsProvider .setCredentials (authScope , new NTCredentials (remoteWebDriverProxyUser ,
870
865
remoteWebDriverProxyPassword , remoteWebDriverProxyWorkstation , remoteWebDriverProxyDomain ));
866
+ clientBuilder .setDefaultCredentialsProvider (credsProvider );
871
867
}
872
868
873
869
// Set the RoutePlanner back to something that handles
874
870
// proxies correctly.
875
- client .setRoutePlanner (new DefaultHttpRoutePlanner (client .getConnectionManager ().getSchemeRegistry ()));
876
871
HttpHost proxy = new HttpHost (remoteWebDriverProxyHost , Integer .parseInt (remoteWebDriverProxyPort ));
877
- client .getParams ().setParameter (ConnRoutePNames .DEFAULT_PROXY , proxy );
872
+ clientBuilder .setRoutePlanner (new DefaultProxyRoutePlanner (proxy ));
873
+ clientBuilder .setProxy (proxy );
878
874
} catch (SecurityException e ) {
879
875
throw new SeleniumLibraryFatalException (
880
876
String .format ("The SecurityManager does not allow us to lookup to the %s field." , fieldName ));
@@ -884,9 +880,6 @@ protected void setRemoteWebDriverProxy(HttpCommandExecutor httpCommandExecutor)
884
880
} catch (IllegalArgumentException e ) {
885
881
throw new SeleniumLibraryFatalException (
886
882
String .format ("The field %s does not belong to the given object." , fieldName ));
887
- } catch (IllegalAccessException e ) {
888
- throw new SeleniumLibraryFatalException (
889
- String .format ("The SecurityManager does not allow us to access to the %s field." , fieldName ));
890
883
} catch (ClassCastException e ) {
891
884
throw new SeleniumLibraryFatalException (
892
885
String .format ("The %s field does not contain a %s." , fieldName , className ));
0 commit comments