Closing Safari push notification dialog in Browserstack - selenium

We're using Browserstack to automate testing of my website. The website uses push notifications and so Safari prompts the user with a dialog asking for permission to send push notifications. This dialog blocks interaction with the browser and the test fails. We've tried browser.switchTo().alert().accept() as well as browser.switchTo().window() to close it or switch back to the website, to no avail.

Related

Instant App link in SMS does not work

I have created an Instant App that works perfectly when I click its link in an email. When I send the same link in an SMS and click it, the default-url is displayed. I am using AS3.2 Canary 9. Has anyone seen the same thing?
This depends of the message app of your phone. Sometimes the message app have an internal web view to manage the urls. In this case the link is directly open in web browser.
If the link is open in the default browser, you should go in this browser app settings and check the links already set as manage by this browser. Or clear the cache of the browser. if it s still not working, go in :
Settings -> Google -> Instant app, then disable an enable it again.
if it s still not working, make it sure by rebooting the device.

Javascript Facebook sdk - captive portal on mobile devices

We are setting up a web app which serves as a wi-fi hotspot using coova chilli and the Javascript Facebook SDK.
The app has a "login with facebook" button that, once clicked, calls the FB.login() function, which opens a pop-up window where the user can insert his credentials and log in.
This solution is working correctly in desktop browsers but it's not working in mobile devices.
These are the problems I encountered:
Android device - When I connect to the wifi network, the system prompts a notification who says "Sign in to wifi network". Once clicked, the captive page opens up correctly. But when I click the fb login button, I am redirected to the url "http://m.facebook.com/v2.8/auth ..." which is correct, but then the windows freezes and I can see only a wsod.
IOS device - same as before, the cna triggers, the redirect to the fb login page works, but once I insert my credentials, the only thing I can see is a wsod.
Both issues can be bypassed by including apple.com, google.com and other domains used for auth in the hotspot walled garden, and then the user can log in to the network by using the device's browser - Safari or Chrome, it works - as pointed out in this discussion Facebook login on Apple CNA.
The thing is, we want to make it work on the "normal" workflow, that is, to make the app work correctly within the IOS captive network assistant and the Android "sign in to wi fi" functionality.
Do you have any idea how can we solve this? We searched far and wide without any success. Thank you.
EDIT
Solved by using PHP SDK instead of javascript. By generating a login link as explained here. This works also on mobile captive portal assistants such as ios and android ones because the fb login page is opened in the same window and not in popup/iframe. I hope this helps others that may encounter the same problem.

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.

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

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.

Detect closing of mobile Safari

I'm building a WebApp which uses video server push with:
<img id="vidsrc" src="video.cgi"/>
It works. And when saved as a WebApp using "Add to Home Screen" closing the app does as expected and stop receiving the server push.
However when running in mobile Safari, only closing the page will get it to stop. What I'm trying to figure out is how to get it to stop if the user clicks the Home button and closes mobile Safari so the push doesn't keep running in the background.
Because of what I've got to work with, editing video.cgi is not an option. And using video.cgi in an iframe isn't a good solution because of some other functionality in the page/app.
onBlur and onClose don't seem to do it, and I'm wondering if there's any way an HTML page or the good stuff in it can know that mobile Safari has been closed.
Unfortunately, you can't... Web apps are not allowed to access the device's software, so are not told when you have pressed the button.