Skip to content

Alert API Implementation for iOS - #459

Merged
TikhomirovSergey merged 1 commit into
appium:masterfrom
SrinivasanTarget:alerthandling
Aug 19, 2016
Merged

Alert API Implementation for iOS#459
TikhomirovSergey merged 1 commit into
appium:masterfrom
SrinivasanTarget:alerthandling

Conversation

@SrinivasanTarget

@SrinivasanTargetSrinivasanTarget commented Aug 16, 2016

Copy link
Copy Markdown
Member

Change list

Alert Handling for iOS.Added below methods,

1)getAlertText
2)setAlertText(String value)
3)acceptAlert
4)dismissAlert

API is here: https://github.com/appium/appium-base-driver/blob/master/lib/mjsonwp/routes.js#L403

API's were not implemented for Android Driver on server side.We can port it to android driver on client side post server implementation.

New W3C API's here: https://github.com/appium/appium-base-driver/blob/master/lib/mjsonwp/routes.js#L414 are not been adapted by Appium (Legacy drivers on server) yet.

Types of changes

What types of changes are you proposing/introducing to Java client?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

@TikhomirovSergey please review

@TikhomirovSergey

TikhomirovSergey commented Aug 16, 2016

Copy link
Copy Markdown
Contributor

@SrinivasanTarget
Like this solution but I am not agree with this implementation. It duplicates methods of the org.openqa.selenium.Alert API. Why could we use Selenium API more high? Like the sample below.

publicclassIOSDriver<TextendsWebElement>
extendsAppiumDriver<T>
implementsIOSDeviceActionShortcuts,
FindsByIosUIAutomation<T> {
...
@OverridepublicTargetLocatorswitchTo() {
returnnewInnerTargetLocator();
}
privateclassInnerTargetLocatorextendsRemoteTargetLocator {
@OverridepublicAlertalert() {
returnnewIOSAlert(super.alert());
}
}
classIOSAlertimplementsAlert {
privatefinalAlertalert;
IOSAlert(Alertalert) {
this.alert = alert;
}
@Overridepublicvoiddismiss() {
alert.dismiss();
}
@Overridepublicvoidaccept() {
alert.accept();
}
@OverridepublicStringgetText() {
Responseresponse = execute(DriverCommand.GET_ALERT_TEXT);
returnresponse.getValue().toString();
}
@OverridepublicvoidsendKeys(StringkeysToSend) {
execute(DriverCommand.SET_ALERT_VALUE, prepareArguments("value", keysToSend));
}
@OverridepublicvoidsetCredentials(Credentialscredentials) {
alert.setCredentials(credentials);
}
@OverridepublicvoidauthenticateUsing(Credentialscredentials) {
alert.authenticateUsing(credentials);
}
}
}

@TikhomirovSergey

TikhomirovSergey commented Aug 18, 2016

Copy link
Copy Markdown
Contributor

There are new checkstyle issues:
image

@SrinivasanTarget Please get it fixed

.IosUIAutomation(".elements().withName(\"show alert\")")).click();
WebDriverWait wating = new WebDriverWait(driver, 10000);
wating.until(alertIsPresent());
assertNotNull(driver.switchTo().alert().getText());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SrinivasanTarget
I would like to advive you to

assertTrue(!StringUtils.isBlank(driver.switchTo().alert().getText()));

What if the empty string would be returned? :)

@SrinivasanTarget

Copy link
Copy Markdown
MemberAuthor

@TikhomirovSergey Thanks.I have incorporated the changes now and squashed the commits.

Implementation changes
Fixed Checkstyle issues
Fixed Checkstyle issues
@TikhomirovSergey
TikhomirovSergey merged commit 1e61110 into appium:masterAug 19, 2016
@SrinivasanTarget
SrinivasanTarget deleted the alerthandling branch August 20, 2016 06:26
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@SrinivasanTarget@TikhomirovSergey