Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Commit 805a76a

Browse files
committed
Test working with Selenium 4 alpha
Fixed deprecations in the remove calls
1 parent cbe8ecb commit 805a76a

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

pom.xml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.github.hi-fi</groupId>
77
<artifactId>robotframework-seleniumlibrary</artifactId>
8-
<version>3.141.59.265-SNAPSHOT</version>
8+
<version>4.0.0-alpha-1.0-SNAPSHOT</version>
99
<packaging>jar</packaging>
1010

1111
<name>Robot Framework :: SeleniumLibrary</name>
@@ -70,8 +70,8 @@
7070
<aspectj.version>1.9.1</aspectj.version>
7171
<java.version>1.8</java.version>
7272
<robotframework.maven.plugin.version>1.5.1</robotframework.maven.plugin.version>
73-
<robotframework.version>3.1.1</robotframework.version>
74-
<selenium.version>3.141.59</selenium.version>
73+
<robotframework.version>3.1.2</robotframework.version>
74+
<selenium.version>4.0.0-alpha-1</selenium.version>
7575
<keywords.class>SeleniumLibrary</keywords.class>
7676
<browser>jbrowser</browser>
7777
</properties>
@@ -117,6 +117,16 @@
117117
<groupId>io.appium</groupId>
118118
<artifactId>java-client</artifactId>
119119
<version>7.0.0</version>
120+
<exclusions>
121+
<exclusion>
122+
<groupId>org.seleniumhq.selenium</groupId>
123+
<artifactId>selenium-support</artifactId>
124+
</exclusion>
125+
<exclusion>
126+
<groupId>org.seleniumhq.selenium</groupId>
127+
<artifactId>selenium-api</artifactId>
128+
</exclusion>
129+
</exclusions>
120130
</dependency>
121131
<dependency>
122132
<groupId>org.apache.commons</groupId>
@@ -126,7 +136,7 @@
126136
<dependency>
127137
<groupId>com.machinepublishers</groupId>
128138
<artifactId>jbrowserdriver</artifactId>
129-
<version>1.0.1</version>
139+
<version>1.1.0-RC1</version>
130140
</dependency>
131141
<dependency>
132142
<groupId>org.mockito</groupId>

src/main/java/com/github/markusbernhardt/seleniumlibrary/keywords/BrowserManagement.java

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
import org.apache.http.auth.AuthScope;
2020
import org.apache.http.auth.NTCredentials;
2121
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;
2526
import org.json.simple.JSONArray;
2627
import org.json.simple.JSONObject;
2728
import org.json.simple.JSONValue;
@@ -39,8 +40,6 @@
3940
import org.openqa.selenium.firefox.FirefoxProfile;
4041
import org.openqa.selenium.ie.InternetExplorerDriver;
4142
import org.openqa.selenium.ie.InternetExplorerOptions;
42-
import org.openqa.selenium.opera.OperaDriver;
43-
import org.openqa.selenium.opera.OperaOptions;
4443
import org.openqa.selenium.remote.Augmenter;
4544
import org.openqa.selenium.remote.DesiredCapabilities;
4645
import org.openqa.selenium.remote.HttpCommandExecutor;
@@ -63,7 +62,6 @@
6362
import com.machinepublishers.jbrowserdriver.JBrowserDriver;
6463
import com.machinepublishers.jbrowserdriver.Settings;
6564

66-
@SuppressWarnings("deprecation")
6765
@RobotKeywords
6866
public class BrowserManagement extends RunOnFailureKeywordsAdapter {
6967

@@ -164,7 +162,6 @@ public void closeBrowser() {
164162
"| Internet Explorer | internetexplorer, ie |\r\n" +
165163
"| Edge | edge |\r\n" +
166164
"| Safari | safari |\r\n" +
167-
"| Opera | opera |\r\n" +
168165
"| Android | android |\r\n" +
169166
"| Iphone | iphone |\r\n" +
170167
"| JBrowser | jbrowser |\r\n" +
@@ -650,8 +647,6 @@ protected WebDriver createLocalWebDriver(String browserName, Capabilities desire
650647
case "chromeheadless":
651648
case "googlechromeheadless":
652649
return new ChromeDriver((ChromeOptions)desiredCapabilities);
653-
case "opera":
654-
return new OperaDriver(new OperaOptions().merge(desiredCapabilities));
655650
case "safari":
656651
return new SafariDriver(new SafariOptions().merge(desiredCapabilities));
657652
case "jbrowser":
@@ -717,9 +712,6 @@ protected Capabilities createCapabilities(String browserName, String desiredCapa
717712
parseBrowserOptionsChrome(browserOptions, desiredCapabilities);
718713
((ChromeOptions)desiredCapabilities).setHeadless(true);
719714
break;
720-
case "opera":
721-
desiredCapabilities = new OperaOptions();
722-
break;
723715
case "safari":
724716
desiredCapabilities = new SafariOptions();
725717
break;
@@ -856,25 +848,29 @@ protected void setRemoteWebDriverProxy(HttpCommandExecutor httpCommandExecutor)
856848
className = "DefaultHttpClient";
857849
Field field = HttpCommandExecutor.class.getDeclaredField(fieldName);
858850
field.setAccessible(true);
859-
DefaultHttpClient client = (DefaultHttpClient) field.get(httpCommandExecutor);
851+
HttpClientBuilder clientBuilder = HttpClientBuilder.create();
852+
//DefaultHttpClient client = (DefaultHttpClient) field.get(httpCommandExecutor);
860853

861854
// set the credentials for the proxy
862855
AuthScope authScope = new AuthScope(remoteWebDriverProxyHost, Integer.parseInt(remoteWebDriverProxyPort));
856+
CredentialsProvider credsProvider = new BasicCredentialsProvider();
863857
if (remoteWebDriverProxyDomain.length() == 0) {
864858
// BASIC Authentication
865-
client.getCredentialsProvider().setCredentials(authScope,
859+
credsProvider.setCredentials(authScope,
866860
new UsernamePasswordCredentials(remoteWebDriverProxyUser, remoteWebDriverProxyPassword));
861+
clientBuilder.setDefaultCredentialsProvider(credsProvider);
867862
} else {
868863
// NTLM Authentication
869-
client.getCredentialsProvider().setCredentials(authScope, new NTCredentials(remoteWebDriverProxyUser,
864+
credsProvider.setCredentials(authScope, new NTCredentials(remoteWebDriverProxyUser,
870865
remoteWebDriverProxyPassword, remoteWebDriverProxyWorkstation, remoteWebDriverProxyDomain));
866+
clientBuilder.setDefaultCredentialsProvider(credsProvider);
871867
}
872868

873869
// Set the RoutePlanner back to something that handles
874870
// proxies correctly.
875-
client.setRoutePlanner(new DefaultHttpRoutePlanner(client.getConnectionManager().getSchemeRegistry()));
876871
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);
878874
} catch (SecurityException e) {
879875
throw new SeleniumLibraryFatalException(
880876
String.format("The SecurityManager does not allow us to lookup to the %s field.", fieldName));
@@ -884,9 +880,6 @@ protected void setRemoteWebDriverProxy(HttpCommandExecutor httpCommandExecutor)
884880
} catch (IllegalArgumentException e) {
885881
throw new SeleniumLibraryFatalException(
886882
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));
890883
} catch (ClassCastException e) {
891884
throw new SeleniumLibraryFatalException(
892885
String.format("The %s field does not contain a %s.", fieldName, className));

0 commit comments

Comments
 (0)