Appium Detect Alertdialog - appium

I'm writing a UI test script in Python, after performing a click, there might be an alert window popping up. If so, I need to press a button on that window. I wonder if there's a way to detect alert dialogs in Appium API? Thanks.

simple and best way is doing through capabilities
capabilities.setCapability("autoAcceptAlerts",true);
This will only accept alerts from your App and not the system Alerts.

Place your pointer on Yes, No button, you will get ID's of those if they have separate ID's. Then use
self.driver.find_element_by_id('id of the button').click()
If they do not have ID then use
self.driver.find_element_by_name('OK').click()

I think this is a bit unrelated to the question, but I hope this will give you a clue.
You can use the XPATH to locate the element. well, this approach is not really recommended. But this could be useful if the element is doesn't have any ID, accessibility name, name, or label. where the information is only class, and value.
for example you could do something like this:
//android.widget.Button[contains(#text,'OK')]
I am not sure about the class name for Alert dialog on android. But this is my approach when facing some problem on iOS automation, for example my app have custom alert with 3 button (all of them is customized), button Open, Close, and Report:
//UIAAlert[*]//UIAButton[#name='Report']
You could do same approach to locate any element which is unable to locate by normal approach.

Related

don't store data in input fields with Vaadin and Edge

I use Vaadin7 and I develop my application and test it with Edge. When I enter information in my input fields, I remark than Edge store data like this (see screenshot). My question is can we block with Vaadin the message in my input fields ? I don't want change parameter in my browser Edge but I would like to do it in my code.
Best regard.
Thank you
Screenshot
It's a tad complicated.
First of all, there is no standard way of doing this. There is the non-standard attribute autocomplete that, when set to off, seems to work (or at least have worked at some point in time, see Disable browser 'Save Password' functionality) but only in non-edge browsers. One trick seems to be to use some kind of hiding/obfuscation (which I would consider a bad idea and probably leads to accessibility issues) like mentioned here: https://stackoverflow.com/a/2555771/10493440. A current approach is using invalid data: https://stackoverflow.com/a/52608082/10493440
I would not suggest any of that as it might break at any time without warning. Changing your browser's setting is the proper way to go even if that might feel unsatisfactory.
For the Vaadin part: Give your field an ID and then apply any of the suggestion above via JavaScript.execute(...) method.

How to open a vaadin combobox programmatically

I have implemented a poor-mans-searchbox using a combobox. The search expression is typed into the textfield and the user press enter. Then the search expression is added to the combo model, this is caught in the eventhandler which then runs the search, empties the combo list and populates it with the searchresults instead. However, the user then need to open the combo list manually (by pressing the little down-arrow) to see the result. It'd be nice to open the list automatically, but I haven't found out how to do that. Does anyone know?
Also the search should be performed each time the user presses a key, and not only after enter is pressed.
Not as the poor man's solution, but you may extend the client side to do that. Tipically, the client side widget would have some method like "openResultsBox" or something similar. You could call that to open up the box. Vaadin 7 also allows you to write extensions which basically lets you extend the client side for exactly doing the very same slight changes. I am not sure why you have chosen the combobox for that though.
the vaadin-combo-box component offers a method called "open" so simply call
reference-to-element.open();
Should do the trick.
Relevant official docs here:
https://www.webcomponents.org/element/vaadin/vaadin-combo-box/elements/vaadin-combo-box#method-open

Am I not understanding UIActivityViewController, or does the implementation currently suck?

I'm trying to move my app to use UIActivityViewController, rather than UIActionSheet, so that I get the fancy graphical sharing buttons rather than the textual buttons. (My app is targeted at iOS 6 only.)
After trying to work with it for a couple nights, it seems either I am totally misunderstanding how to use it, or the current implementation by Apple is terrible:
You can't specify a different message for different services. If I want something that will work across: Mail, Facebook, Messages AND Twitter, it's going to need to be 140 characters max, to work on Twitter. Is there a way to set custom content for each type of activity?
There appears to be no way to set a subject line or recipient for Mail messages. I've read the docs, they make it sound like this might be possible with an NSURL that uses the mailto: protocol, but in my tests, those URLs just get shoved into the message body. Is there actually a way to set the subject line and optionally, the recipients?
If I want to work around these shortcomings, and do my own custom activities by subclassing UIActivity, I have to use a custom image/icon. Therefore, I can't mimic the Mail activity with Apple's official icon, and e.g. implement my own custom activity backend that actually lets me set the subject line, recipients, custom body, etc. Am I wrong, is there a way to use Apple's service icons, but have a chance to customize the behavior? (The only callback I see is one that runs AFTER the activity has been completed, right?)
I hope I'm wrong!
Is there a way to set custom content for each type of activity?
Yes, I guess you should subclass UIActivityItemProvider and override method –activityViewController:itemForActivityType: with your logic (e.g. trim string to 140 chars for Twitter).
Then pass an instance of this class to -[UIActivityViewController initWithActivityItems:applicationActivities:].
Is there actually a way to set the subject line and optionally, the recipients?
You are right, the mailto scheme should be able to set these fields. If it is not working, I consider this as bug. (Didn't try this myself, but I will give it a check.)
Is there a way to use Apple's service icons, but have a chance to customize the behavior?
I think you can't do this. (Unless you want to hack those system activities.)
You are better off using a custom component that behaves like UIAcitvityController as it is quite limited, as you noted.
This is one example: https://github.com/hjnilsson/REActivityViewController , I just forked it from https://github.com/romaonthego/REActivityViewController to allow you to set the email subject field.

CakePhP jquery debuging modal dialogs data flow

I have quite a big application, sometimes with pretty complicate data being created by the user (on the way to the database the data is being altered a lot). The issue is, that any time I need to alter the code, I get stuck for quite a few hours before finding the problem.
Actions in my app:
User opens the jquery modal dialog
There is a form in the modal dialog
User alerts the data and saves it
About app:
The application contains of one site with a table and several buttons
Each of these buttons open a different modal dialog
Each form submission is handled via ajax -> cakephps this->js->submit
How I wrote the code:
For each modal dialog I created an element
After clicking the button I open the element as a jquery modal dialog
Lots of these modals gain information via for example: "On click/on double click etc" events.
My problem:
Every time I alter the cakephp code which is called by $this->Js->submit I feel like putting a gun to my face and pulling the trigger.
I dont know of any easy way of how to debug variables in these functions (cakephps debug doesnt show anything ofc -> the view of those ajax/php functions are not in the main site)
Dont know if firebug has any features for debugging php, but I dont know of any.
The only thing that works for me a bit is commenting out lines of code and putting an alert in the success like this to maybe sometimes get to the values, but it doesnt feel right.
Being used to write code in c++/java and printing or debugging with breakpoints makes me frustrated, when I use such a modern programming language and try to guess out where the bugs might be..
Most errors:
Mostly null pointers or checking !isset index being accessed, but since I know of no way of printing these errors from modals no checking on the indexes helps me.
Use FirePHP it is a great enhancment of firebug. Works well.

ios - what is the conventional method to display errors and messages to the user?

I am an Android user, and just learning ios so I am not too familiar with some of the UX details.
If an app has a form that needs a success message, or a message about a validation error, what is the conventional way of accomplishing this in ios?
Thank you!
The conventional way of presenting success is to present nothing. You might refresh data or navigate with an animation, but mostly you should just get out of the way.
The conventional way of presenting errors easily is to use a UIAlertView, offering a clear, concise message on what went wrong and how to fix it if possible.
Don't constrain yourself to stock controls that make it easy, though. There are many other, gentler ways to indicate failure than a modal popover (which is what the alert view is). Take a look at Tweetbot. They use a non-modal banner view to indicate both success and failure, such as when the network can't be reached. This is an especially good idea if the error is transient, since it doesn't require user interaction to dismiss.
Validation errors are often done with a UIAlertView.
Success confirmations could be done with a "toaster" notification (as seen in Tweetbot's iPhone app, here: http://shawnblanc.net/images/tweetbot-notifications.jpg), though this would require custom code.
UIAlertViews could also be used for a success message, but since it's highly interrupting, it's probably not ideal.
I used UIAlertView class. Here is the link to Apple's doc on this class.

Resources