EggPlant Script Hanging on If-Statement - eggplant

I have a simple script to open the Apple Maps app and then click the "Allow" option that appears if you haven't allowed the app your location in Settings.
Click "AppIcon_Maps"
If ImageFound(text:"Allow") then click it
PressHomeButton
However, when I run my script, Eggplant clicks on the Apple Maps icon and then never completes the if-statement. In fact, while running the script, the Apple Maps app never opens at all! When I abort the script it does open, though. Any ideas for why this happens? Maybe I don't understand how the ImageFound() works yet.

Well...I don't think there's a happy answer here. It appears the ImageFound() freezes the SUT as it searches the screen, and I need to define a very long wait (12 seconds) to give the SUT ample time to open the app so that when ImageFound() freezes the screen, the text could appear.
It still requires a different approach, though, because when the text "Allow" is not on the screen, it takes about 10 minutes to reach this conclusion. Looks like OCR may not be a great approach on app, because it only takes a few seconds to determine than an image isn't present.
Unfortunate that OCR is so slow in this context, because it's so useful for cross-platform scripts, but it's problematic in this instance.

Related

Will providing a user-selectable option to quit an iOS app result in its rejection by Apple

I am working on an app that I feel would enhance the user experience if it provided an option for users to quit the app. This option would only be available from one of its screens.
I have researched this idea and I am fully aware of the following:
Technical Q&A QA1561
Quit iOS Application Programmatically with UIAlertView
Is it possible to quit iOS app after we do some checks
However, what I am proposing is a situation where one of the screens provides users with a range of options via a number of buttons. Each button has an icon and is clearly labelled.
Since the Quit App option would allow users to manually quit the app, the user will not then think the app has crashed. And, because the function of the button is to quit the app, then this isn't a case where the app was unable to provide its intended function. In fact, it's the exact opposite as the intended function is to quit the app.
My question is:
If this is a user-selectable option that is clearly labelled in terms of what it does, will Apple still reject it? If so, would it make any difference if the app provided a 'confirmation alert' after the user selects the option?
I am hoping that someone can either:
share their experience of having tried the same approach
refer me to an existing app that does this (as an example that it would be approved)
Actually about this Apple provide detailed answer in this link.
Kindly follow it.
Basic Snapshot :
In iOS, the user presses the Home button to close applications. Should
your application have conditions in which it cannot provide its
intended function, the recommended approach is to display an alert for
the user that indicates the nature of the problem and possible actions
the user could take — turning on WiFi, enabling Location Services,
etc. Allow the user to terminate the application at their own
discretion.
Apple is says gave the Warning to developer to do not call exit methods forcefully.
Warning: Do not call the exit function. Applications calling exit will
appear to the user to have crashed, rather than performing a graceful
termination and animating back to the Home screen.
If during development or testing it is necessary to terminate your application, the abort function, or assert macro is recommended.
Hope this will help you.

Is it possible to make my iPhone 4s ping its location to a server every time the volume button is pressed?

I am fine with Jailbreaking the phone if it helps.
I'm trying to make my iPhone 4s ping its current location to a server every time the volume is pressed.
Here are the main steps for the desired functionality
Press the volume button. Ideally, this should only trigger the next event if the phone is locked.
The iPhone gets it location and makes a HTTP POST to send it to my server.
I haven't actually done any iOS programming, but I'm wondering if this is possible and what are the main steps I would take to begin learning the technologies required and building.
Thanks.
You should be able to detect the button press programmatically, and from that point you can handle it however you'd like. More information about that already exists in a question/answer made previously in this year:
Detect Volume Button Press
From here, in order to get the location, you'll have to use the CLLocationManager class. There is documentation on Apple's developer website that actually shows you exactly how to do this task.
Furthermore, you'll want to check out the Apple developer page for using NSURLConnection, and find the section about making an HTTP POST request: NCURLConnection Documentation
In order to be able to do this, you would likely have to have knowledge of: Swift/Objective-C, iOS, PHP, and HTTP. You also probably want to have the determination to do a bit of research. You won't be able to get this all done by copying and pasting code. However, you shouldn't have to jailbreak the iPhone. Just some solid programming work will get you the functionality you want.
Hope this helped.

How to get back to the application which escapes control?

Scenario :
"My application may escape control during UI automation to another application like the browser etc"
Solution :
"I want to get back to my application which I am automating after it loses control and moves to another app so that I can proceed with my automation"
Tried :
I can figure out if an application escapes control by checking the bundle id's after each action so that if the actual and current bundle id's differ I get to know that my application lost control.
I am blocked on how to proceed further in getting back to my application in case it moves out of control
Thank you for your time and effort in going through till the end :)
This is a limitation of the "sandbox" in iOS -- once your app loses focus, UIAutomation must terminate as well. You will need to launch another instruments session to automate the browser (or whatever application you're switching to).
See this question for some information on launching an automation session against those apps.

How to reset an iOS app, using UIAutomation instrument, if the app does not have sign out option

I want to test the sign in screen and once I complete one test, my app is signed in but for the next test I want to sign out and go to the first screen again. (PS: App does not have a sign out).
Is there any way out that I can clear application data without uninstalling the app so that I can resume my tests from the first screen without any break.
Or please suggest if there is any other option.
You could try cmd-shift-hh? then swipe the app up, then you can test the app again
This kind of feature is important, because in the case where the app fails a test (and is therefore in an unknown state), you want a reliable way to return to a known state -- like the first screen.
The bad news is that Apple doesn't give you this within instruments.
One way to do to it is to take advantage of the shake gesture -- assuming that you don't need it for other things in your app -- so that in a UIAutomation build, calling target.shake() will return you to your first screen.
Another way to do it would be to instrument your code so that you can send a reset signal from the shell as part of your test. In our framework (called Illuminator), we provide an automation bridge to accomplish this.
driver.resetApp(); It may work. try this.

iOS system hangs before opening App Store URL

I have a HTML page with a Download app button. When clicked by an iOS user, it redirect the users to the App Store via itms-services. The link I used here is:
window.location.replace("itms-apps://itunes.apple.com/app/id578505616");
It looks like so on a mobile browser:
Facebook/Pinterest has an in-app browser which asks for the user's consent before redirect the user out of their app in the form of an Alert box with Cancel or Open app, which Open app opens the external link. It looks like this:
It looks like this with the Alert box:
Assuming the user is using an iOS device. The expected behavior here is when the Open app button is clicked, the user gets redirected to the App Store app. However, we are seeing about a 10 seconds delay before the actual redirection happens.
See videos below:
https://www.youtube.com/watch?v=_dgh7v-IsK8
https://www.youtube.com/watch?v=_LFHeRnBFgg
https://www.youtube.com/watch?v=82Y-kj-pMyw
Notes:
I can't seem to reproduce this at all times. It is only reproducible sometimes. Sorry!
Once a device is delayed for the first time, all subsequent links to AppStores will be fast, until roughly 1 day late. Rebooting the phone and/or clearing the browser cache and/or reinstall Facebook/Pinterest does not help reproducing this.
I tried to replace the itms-apps:// link with https://itunes.apple.com/us/app/trusper-tips-tutorials-how/id578505616?mt=8, but we were still experiencing the delay from time to time.
The delay seems to be exactly 10 seconds.
Why does this delay occur? This seems like a bad user experience.
My current theory is that the problem is on the Apple side. The reason being, once the Open app button is clicked, it is out of the hand of our website, as well as Facebook/Pinterest app. I presume, once the button is clicked, iOS is handling the actual context switch from one app to another. Therefore, it suggests that either the system call actually opening the URL is hanging, or the system call opening the App Store app is?? However, I haven't been able to prove either one to be true or false. Does anyone have a better explanation?
[Edit 04/02/2015]
I can confirm this problem still exists as of today on my phone (iPhone 5S w/ iOS 8.2).
I did some further research and found this article which I think is suggesting that this is a iOS system-related bug: OpenUrl freezes app for over 10 seconds
As there is no proper documentation on how it works, it is hard to pinpoint the cause of it.
Let me advance a theory.
Opening an app from browser causes a context switch; indeed from browser to App Store. So for the very first time it'd cost some time, while in subsequent times it will open faster as it will get opened from cache.
If you consider AppStore uses Keep-alive connection between iOS AppStore in device and iOS AppStore Server for the first time socket opening in server would seem higher than the subsequent times as subsequent request would reuse the same connection.
If the app is removed from the cache then it'd again take some time for the app to open and there would be a little network delay as the app would have lost the cookie for keep-alive connection then the app would have to endure the socketing opening cost.
There are also other factors like Safari hanging, resulting in some delay. You can read how Safari can be messed up here.
iOS doesn't have garbage collection, only things like ARC (Automatic Reference Counting). Each has its own advantages and drawbacks. Sometimes these drawbacks can surface and cause some problem; nothing is to be ruled out. For example a memory leak or app-crash might leave dangling pointers.
Technically, using itms-apps should give a little advantage over plain iTunes url because itms-apps should narrow down the search; itms-apps mean iTunes Music Store-apps.
A plain iTunes URL may be a Book (iBook), Music (iTunes), App (Appstore), etc ... so iOS might have to decide which app to launch.
I hope this helps.

Resources