Dismissing UIAlertController in Earl Grey - earlgrey

I've been having a hard time trying to dismiss UIAlertControllers in Earl Grey. I followed the example in this example, but I cannot dismiss the alerts by using grey_text. I'm using Swift to write the tests where I need to dismiss the alerts, and the app is written in Objective-C.
So how can I dismiss the alerts via the Earl Grey framework? I've also used grey_accessibilityLabel with no luck, and I can't add an accessibility ID to a UIAlertController, to my knowledge.

I was able to assert a UIAlertController and perform an action on the same using the following code:
EarlGrey.select(elementWithMatcher: grey_text("You are about to exit")).assert(grey_sufficientlyVisible())
EarlGrey.select(elementWithMatcher: grey_text("The information you have entered will not be saved.")).assert(grey_sufficientlyVisible())
EarlGrey.select(elementWithMatcher: grey_text("Confirm")).assert(grey_sufficientlyVisible())
EarlGrey.select(elementWithMatcher: grey_text("Cancel")).perform(grey_tap())
Using the matcher grey_buttonTitle("Cancel") did not seem to be working.

Related

How to remove 'cancel button' in a ResearchKit survey

I've made a ResearchKit survey with 11 steps, but I'd like to remove the default cancel button that's on the bottom of every question.
I've come across this command:
stepViewController.cancelButtonItem = nil;
But I can't seem to find the right place for it.
Thanks.
The correct place would be in the delegate callback. The documentation states "The cancel button item is updated during view loading and when the value of the step property is changed, but is safe to set in the taskViewController:stepViewControllerWillAppear: delegate callback."
And as an example:
func taskViewController(_ taskViewController: ORKTaskViewController, stepViewControllerWillAppear stepViewController: ORKStepViewController) {
stepViewController.cancelButtonItem = nil
}
That being said, the functionality currently seems to be broken in the most recent version of ResearchKit per these issues on their repo.
https://github.com/ResearchKit/ResearchKit/issues/1273
It currently will disable the functionality of the cancel button, but does not correctly remove the button from the ORKNavigationContainer. If you find a solution, please let me know, had the issue posted on their repo as well as a few other places for some time now with no luck.

How can I use mnemonics on JavaFX 8 Alerts

I would like to be able to add accelerator keys for the buttons that are provided as a part of the Alert Dialog Controls included with JavaFX.
I am unsure if this is possible using the standard alert types ERROR, INFORMATION, CONFIRMATION, WARNING?
I created my own login window - which doesn't use an Alert structure and it works as follows:
When the stage opens up.
Then when the user hits the "ALT" key:
I would like the ability to "Hot Key" the buttons on the Alerts in the system. However, I am unsure if I can use the standard alerts, or if I need to create my own, and if so, how should I do that.
I really would like to use the Dialogs natively, if at all possible.
Thanks.
As far as I understood your question, I think it isn't possible without some extra code.
Looking at the code of OpenJFX the labels of the buttons are localized and fixed.
You might just want to create some buttons on your own by using the apropiate constructor which takes some buttons where you can override the existing ones.
EDIT: after rethinking everything, I tried to recreate your problem. You can see that project on GitHub..
This is the special code:
public void showCustomizedAlertWindow() {
Alert a = new Alert(AlertType.CONFIRMATION, "some content text", ButtonType.OK, ButtonType.CANCEL, ButtonType.FINISH);
((Button) a.getDialogPane().lookupButton(ButtonType.FINISH)).setText("_finished");
a.show();
}
But be aware, you are removing localization-support of that buttons.

UILocalNotification actions and snoozing

I'm working on a custom app for a client and am still relatively new to iOS development. The app involves setting reminders and I'm using UILocalNotifications. Now from my research the action on the notification will always run the app but I'm really hoping someone can correct me on that. Also from what I've read you are limited to the 'View' or 'Close' options. Ideally I'd love to have 3 buttons on the notification and not have to open the app to perform an action.
I'd like a 'dismiss' option, 'snooze' option, and an 'ok' option that dismisses the notification but runs some code in the background.
I came across a notification related question where somebody suggested opening the app with a modal view and presenting the options from there. Possible, just not as clean, I guess.
Any other ideas or is this what I have to do to achieve my desired functionality? If that's the case is there a way to close the app after I've selected one of my options from the modal view?
Thanks in advance.
That is not possible, as the notification is not created by your app but by the system, so you can't customize the appearance of the notification. (also in iOS 5, the user can choose to display the notifications as banners instead of alerts, which would hide any other button than the view and close button, if that were to be possible).
Secondly there is no way to close your app, as iOS is a user centric system, where the user takes the decision on whether to open or close app, and not the app itself.

How to create input text controller like in the iphone message app

I want to do a chat app like the iphone message app. I use a UITableView to show the messages and under it i want to put some input text controller and a send button. the problem is that if i use a UITextField for the input controller it does not wrap the words and it does not look like the iphone message app controller.
how can i get the look&fill of the original controller?
Here you have an open source of project that you're trying to develop. I think this will help: cocoacontrols.com. Also on cocoacontrols.com you can find bunch of useful projects so try to look there before reinventing the wheel.
Best of luck
take a look at Chat Input Sample code. It has all the functionality what you needed.

Need new way to add a UITextField to a UIAlertView

So my app was rejected (it has been approved every other time i have put it in for review and I hadn't touched this code path in ages) or this line:
[myAlert addTextFieldWithValue:nil label:NSLocalizedString(#"Name",#"Name")];
Apparently addTextFieldWithValue:label:
is a private API...
so how are we supposed to put a UITextField inside an AlertView?
Can someone help?
Consider using a modal view controller, instead. No risk of app rejection.
You don't. Alert views are for displaying alerts only. Apple uses them to display text fields sometimes, but that's their prerogative (since they wrote the HI guidelines and all).
Find a different approach in your UI for prompting the user for data. This is a mobile platform, not a desktop. Using popups like this for information gathering on such a platform is usually inappropriate.