Skip to content

Commit 16842a8

Browse files
committed
implement the AuthenticateUsing Alert API in java
1 parent 8925c0f commit 16842a8

File tree

11 files changed

+20
-93
lines changed

11 files changed

+20
-93
lines changed

Diff for: java/CHANGELOG

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
v2.47.0 in development
2+
======================
3+
4+
* Beta Alert.AuthenticateUsing api implementation added, beta testing with IE.
5+
16
v2.46.0
27
=======
38

Diff for: java/client/src/org/openqa/selenium/Alert.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package org.openqa.selenium;
1919

20-
import org.openqa.selenium.security.Credentials;
20+
import org.apache.http.auth.Credentials;
2121

2222
public interface Alert {
2323
void dismiss();

Diff for: java/client/src/org/openqa/selenium/BUCK

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ java_library(name = 'webdriver-api',
88
'//java/client/src/org/openqa/selenium/interactions:interactions',
99
'//java/client/src/org/openqa/selenium/interactions:exceptions',
1010
'//java/client/src/org/openqa/selenium/logging:api',
11-
'//java/client/src/org/openqa/selenium/security:security',
1211
],
1312
visibility = ['PUBLIC'],
1413
)

Diff for: java/client/src/org/openqa/selenium/build.desc

-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ java_library(name = "webdriver-api",
8484
":codecs",
8585
"//java/client/src/org/openqa/selenium/interactions:api",
8686
"//java/client/src/org/openqa/selenium/logging:api",
87-
"//java/client/src/org/openqa/selenium/security",
8887
])
8988

9089
java_library(name = "client-combined",

Diff for: java/client/src/org/openqa/selenium/remote/DriverCommand.java

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public interface DriverCommand {
9393
String DISMISS_ALERT = "dismissAlert";
9494
String GET_ALERT_TEXT = "getAlertText";
9595
String SET_ALERT_VALUE = "setAlertValue";
96+
String SET_ALERT_AUTHENTICATION = "setAuthentication";
9697

9798
String SET_TIMEOUT = "setTimeout";
9899
String IMPLICITLY_WAIT = "implicitlyWait";

Diff for: java/client/src/org/openqa/selenium/remote/RemoteWebDriver.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.google.common.collect.Lists;
2525
import com.google.common.collect.Maps;
2626

27+
import org.apache.http.auth.Credentials;
2728
import org.openqa.selenium.Alert;
2829
import org.openqa.selenium.Beta;
2930
import org.openqa.selenium.By;
@@ -38,7 +39,6 @@
3839
import org.openqa.selenium.Point;
3940
import org.openqa.selenium.SearchContext;
4041
import org.openqa.selenium.TakesScreenshot;
41-
import org.openqa.selenium.UnsupportedCommandException;
4242
import org.openqa.selenium.WebDriver;
4343
import org.openqa.selenium.WebDriverException;
4444
import org.openqa.selenium.WebElement;
@@ -60,7 +60,6 @@
6060
import org.openqa.selenium.logging.NeedsLocalLogs;
6161
import org.openqa.selenium.remote.internal.JsonToWebElementConverter;
6262
import org.openqa.selenium.remote.internal.WebElementToJsonConverter;
63-
import org.openqa.selenium.security.Credentials;
6463

6564
import java.net.URL;
6665
import java.util.Date;
@@ -935,8 +934,18 @@ public void sendKeys(String keysToSend) {
935934
execute(DriverCommand.SET_ALERT_VALUE, ImmutableMap.of("text", keysToSend));
936935
}
937936

937+
/**
938+
* Authenticate an HTTP Basic Auth dialog.
939+
*
940+
* Usage: driver.switchTo().alert().authenticateUsing(new UsernamePasswordCredentials("cheese",
941+
* "secretGouda"));
942+
* @param credentials
943+
*/
944+
@Beta
938945
public void authenticateUsing(Credentials credentials) {
939-
throw new UnsupportedCommandException("Not implemented yet");
946+
execute(DriverCommand.SET_ALERT_AUTHENTICATION, ImmutableMap
947+
.of("username", credentials.getUserPrincipal().getName(), "password",
948+
credentials.getPassword()));
940949
}
941950
}
942951

Diff for: java/client/src/org/openqa/selenium/remote/http/JsonHttpCommandCodec.java

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public JsonHttpCommandCodec() {
9797
defineCommand(DISMISS_ALERT, post("/session/:sessionId/dismiss_alert"));
9898
defineCommand(GET_ALERT_TEXT, get("/session/:sessionId/alert_text"));
9999
defineCommand(SET_ALERT_VALUE, post("/session/:sessionId/alert_text"));
100+
defineCommand(SET_ALERT_AUTHENTICATION, post("/session/:sessionId/authenticate"));
100101

101102
defineCommand(EXECUTE_SCRIPT, post("/session/:sessionId/execute"));
102103
defineCommand(EXECUTE_ASYNC_SCRIPT, post("/session/:sessionId/execute_async"));

Diff for: java/client/src/org/openqa/selenium/security/BUCK

-10
This file was deleted.

Diff for: java/client/src/org/openqa/selenium/security/Credentials.java

-28
This file was deleted.

Diff for: java/client/src/org/openqa/selenium/security/UserAndPassword.java

-43
This file was deleted.

Diff for: java/client/src/org/openqa/selenium/security/build.desc

-6
This file was deleted.

0 commit comments

Comments
 (0)