Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 753
Alert API Implementation for iOS#459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -16,6 +16,7 @@ | ||
| package io.appium.java_client.ios; | ||
| import static io.appium.java_client.MobileCommand.prepareArguments; | ||
| import static io.appium.java_client.ios.IOSMobileCommandHelper.hideKeyboardCommand; | ||
| import static io.appium.java_client.ios.IOSMobileCommandHelper.lockDeviceCommand; | ||
| import static io.appium.java_client.ios.IOSMobileCommandHelper.shakeCommand; | ||
| @@ -27,16 +28,20 @@ | ||
| import io.appium.java_client.remote.MobilePlatform; | ||
| import io.appium.java_client.service.local.AppiumDriverLocalService; | ||
| import io.appium.java_client.service.local.AppiumServiceBuilder; | ||
| import org.openqa.selenium.Alert; | ||
| import org.openqa.selenium.Capabilities; | ||
| import org.openqa.selenium.WebDriverException; | ||
| import org.openqa.selenium.WebElement; | ||
| import org.openqa.selenium.remote.DriverCommand; | ||
| import org.openqa.selenium.remote.HttpCommandExecutor; | ||
| import org.openqa.selenium.remote.Response; | ||
| import org.openqa.selenium.remote.http.HttpClient; | ||
| import org.openqa.selenium.security.Credentials; | ||
| import java.net.URL; | ||
| import java.util.List; | ||
| /** | ||
| * @param <T> the required type of class which implement | ||
| * {@link org.openqa.selenium.WebElement}. | ||
| @@ -220,4 +225,50 @@ public List<T> findElementsByIosUIAutomation(String using) | ||
| public void lockDevice(int seconds) { | ||
| CommandExecutionHelper.execute(this, lockDeviceCommand(seconds)); | ||
| } | ||
| @Override public TargetLocator switchTo() { | ||
| return new InnerTargetLocator(); | ||
| } | ||
| private class InnerTargetLocator extends RemoteTargetLocator { | ||
| @Override public Alert alert() { | ||
| return new IOSAlert(super.alert()); | ||
| } | ||
| } | ||
| class IOSAlert implements Alert { | ||
| private final Alert alert; | ||
| IOSAlert(Alert alert) { | ||
| this.alert = alert; | ||
| } | ||
| @Override public void dismiss() { | ||
| execute(DriverCommand.DISMISS_ALERT); | ||
| } | ||
| @Override public void accept() { | ||
| execute(DriverCommand.ACCEPT_ALERT); | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't you use @Overridepublicvoiddismiss() {
alert.accept();
}instead? | ||
| } | ||
| @Override public String getText() { | ||
| Response response = execute(DriverCommand.GET_ALERT_TEXT); | ||
| return response.getValue().toString(); | ||
| } | ||
| @Override public void sendKeys(String keysToSend) { | ||
| execute(DriverCommand.SET_ALERT_VALUE, prepareArguments("value", keysToSend)); | ||
| } | ||
| @Override public void setCredentials(Credentials credentials) { | ||
| alert.setCredentials(credentials); | ||
| } | ||
| @Override public void authenticateUsing(Credentials credentials) { | ||
| alert.authenticateUsing(credentials); | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you use
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TikhomirovSergey
alert.dismiss()cannot be used asRemoteWebDriverusesRemoteWebDriver.this.execute("dimissAlertW3C")i.e W3C API which we didn't adopt yet. It is the same foralert.accept()as well