How can iOS's Javascript UIAutomation be used to navigate a native app's oAuth process? - ios-ui-automation

Context
Many native apps have the user authenticate with Facebook, rather than with their own authentication system. This has been problematic for me to write iOS UIAutomation testcases with the Javascript bindings. Our scenario, from the user's perspective, typically looks like this.
Scenario
The user clicks "Connect to Facebook".
The (target) applications moves to the background, and a Safari browser moves into the foreground, so the user can authenticate with oAuth.
The user enters their authentication data and submits.
The Safari browser window moves into the background, and the target application moves back into the foreground.
Problem
Before running tests, Instruments has the user set the "target app" in the top menu bar.
Using the Automation within Instruments proves problematic when the target app moves into the background and the Safari app moves into the foreground (Step #2). At this point, Instruments reports
The target application appears to have died
I thought this would be as simple as merely polling/testing for changes in UIATarget.localTarget().frontMostApp() (or something similar), but does not seem to be the case -- the test run stops executing.
How can I use Instruments to successfully test this scenario? Is this a testable scenario with UIAutomation's Javascript bindings?

Alas, this is not possible. Instruments loses it's connection with the app since the app freezes in the background and does not continue. Also, it's not possible to send touch events to Safari because UI Automation doesn't work with apps that you didn't build yourself.
If you're using a pre-built SDK, you're pretty much out of luck. But if you are rolling your own Oauth connection to them, you could present a modal view controller with a webview going to Facebook's Oauth authentication page instead of kicking the user all the way out to mobile Safari.
That way, the application never exits. You can then figure out the events to send to the webview and try testing this from there.

Related

Options for interacting with an alert for signing in through an in-app browser on iOS

We ran into a issue where, after adding a functionality for authentication through an in-app web browser, a new confirmation alert appears in the app, that cannot be targeted by Detox. This alert is at this moment seemingly impossible to handle, since there are no preferences that can be added at the setup of the test.
We actually bypass the entire authentication process once we get into the web browser, but we need to open it in order to call the service and validate that the user that tries to login has the necessary permissions. Also, mocking is not an option, since we use different users between the tests (for testing various feature flags) and that would mean rebuilding the release app for each separate user (at least, that's how I understand the mocking mechanism works). We also tried to tap by coordinates, but Detox validates that there is no system alert present before tapping, which is kind of ironic and funny considering what we are trying to do.
Are there any options for interacting with this popup?

how to disable Push Notifications os popup on ios and avoid to launch app on main page

I am doing automation using Appium and I came across 2 major problems.
How to dismiss SEND/PUSH Notifications popup on iOS which is system popup
If I install the application and uninstalled it and then again installed, It is launching the app with already user signed in. How can I avoid it to launch signed in instead of Showing on Sign in.
To cancel the PUSH Notification, I am using autoAcceptAlerts, which works but not always.
Though ideally uninstall and install shall not have leave the user logged in. But you can try this to logout the user after every relaunch, you can use ((AppiumDriver) driver).resetApp() for resetting the application so that it launches back with the login page.
For dismissing the alerts autoAcceptAlerts should work. Another way to tweak it is to use ((IOSDriver)driver).SwitchTo().Alert().Accept();. You can also try your hands on some methods mentioned here.

windows authentication and iOS7

We are developing a web application in asp.net and HTML5 (+ offline feature) and we are using “Add to desktop” button to create the desktop application.
Before access main screen, we have a windows authentication screen, so people can connect using their domain credentials.
In safari, we have almost no problem. It's the expected behavior when we are online. For the offline mode, safari needs to keep an active tab with the website loaded to allow offline access to it, otherwise safari does not find website – even if it’s cached with cache manifest...
In the desktop application (using “Add to desktop” button), the authentication popup on the main page does not appears. When I trace the HTTP requests, I can see 2 requests with a return status of 401. When I look into the logs, safari sandbox throw an exception (twice tries then abort operation)... The screen remains blank.
any ideas anyone or any fix is planned to correct this problem ?
Thanks in advance for any advices.
It's a problem with iOS 7. Windows Authentication only works in "Private Mode" or in another browser such as Chrome or Puffin. However, there isn't a workaround currently available to save an app to the home screen. Here's a thread on the Apple forums about this same issue:
https://discussions.apple.com/thread/5327078?start=60&tstart=0
The new iOS 7.03 fixes this issue.

How to pass Login With Google Process in Cocoa WebView

I am developing a cocoa app for Mac OSX. It's a basic browser application and I use webview component.
In the page I want to connect, there is standard Login with Google Account button in order to login with my existing Google Account. When I clicked on this button nothing happens.
The same functionality works properly when I visited the same page by using Safari or any other browser but there is no reaction on webview component.
I've checked the action behind the Google's login button and here is the JS code.
onclick="return Dialog.Login.loginWithGoogle(false, 'https://www.mywebsite.com/-/oauth2callback', 'https://www.mywebsite.com/')"
As a part of the standard oauth process the process also has many redirections after this URL is called and normally should be completed at my site's login screen as expected. However, webview doesn't handle this.
Please note that the web site I am trying to connect in my webview is not belong to me and I have no control on it.
I checked many solutions on the web for 2 days but nothing helped.
Any help/hint will be appreciated.

On a Mac how to determine a user logout is occuring

I am very new to the Mac platform and Objective-C in general and in my application I would like to know how to determine that a user is logging out and perform some actions prior to this. Any info or pointers for this?
The official way to put the hook at logging in / logging out is described in these Apple documents Customizing Login and Logout and Tech Note 2228. But I'm afraid that the log-out hook was no longer directly supported.
So, the second best way is to run a headless Cocoa app, and receive a notification from the system using NSWorkspace, see the document and the list of available notifications.
To make a headless Cocoa app, you need to set an entry in its Info.plist called LSUIElement, see here. By setting LSUIElement to be yes, the app don't appear in the dock, but perform various operation in the background.
Take a look at Receiving Workspace Notifications in this Workspace Services document.
NSWorkspaceWillPowerOffNotification
Posted when the user has requested a
logout or that the machine be powered
off.