XCUITest - resetAuthorizationStatus(for:) not working - xctest

I'm trying to use the pretty new resetAuthorizationStatus(for:) method in order to test multiple test cases related the different authorizations (BlueTooth, reminders and location primarily) during UI Tests. But, after using the function, the iOS alert dialog doesn't appear anymore. Does it work for you ?
Thanks

Related

The number of times a custom event happened is not being updated on my dashboard

I've been able to distinguish between the live build and the test build on my Android app. Everything works perfectly on the test version. I can see the live events and when I go and see the number of clicks for an event, that gets updated too. However, on the live build of my app, I can see the live events but the number of clicks is not being updated. All the events still show empty analytics. What could be wrong?
Amruta from Branch.io here:
Based on your description it looks like your App is still using the test key. If your App has both the Live and Test key added to the Manifest, and you have the debug mode enabled, your App will continue using the Test key. You should make sure that your App is using the Live key.
You can ensure that your app is using the Live key by using a Branch link from the Live version of your App. On clicking on the link, the link parameters received in the callback should have the parameter '+clicked_branch_link: true'.
If the parameter 'clicked_branch_link' is set to false it means that your App is still using the test key.
If you still continue to face issues, I would suggest writing to integrations#branch.io and they can help you resolve any issues you are facing.

Capybara Selenium Navigate To URL Hangs With Popup Alert on Safari

At the end of my tests Capybara automatically navigates to "about:blank" in order to set up the next test. Sometimes the application I'm testing will throw a popup alert if the user leaves the page (which is expected). I have some code to handle this:
begin
page.driver.browser.navigate.to("about:blank")
page.driver.browser.switch_to.alert.accept
rescue Selenium::WebDriver::Error::NoAlertPresentError
# No alert was present. Don't need to do anything
end
This works fine on Firefox, Chrome, and IE. But for some reason on Safari the navigate command hangs, I assume because of the popup. Anyone know a workaround for this?
There is no simple workaround for this at this time in any version of Selenium language bindings. It is a known issue the Selenium team is not interested in resolving. Fundamentally, it is due to the architecture of Safari and consequently the architecture of the Safari Driver.
The JavaScript of the Safari Driver extension does not know about most of the alerts and popups and dialogs that appear as modal Cocoa layer windows.
It also cannot interact with them.
There is a way but it won't be easy and nobody's done it.
You would need to use Cocoa.
So you would want to use RubyCocoa in this case.
(or PyObjC if you used Python)
You would then possibly also want a sidecar app actually written in Objective-C.
The trick would be to use the AX (Accessibility API) and a separate process to observe if there is an alert as the front window and poke at its labels and buttons' text as visible to the AX APIs.
AX APIs are probably exposed in RubyCocoa via the ScriptingBridge.
However, you would need to add your 'app' to the Security preference pane's list of things allowed to control the computer.
With that, you could detect the window and handle it.
It could be fairly brittle across web sites, but if built well, you could handle expected conditions.
You could try to confirm like this which I believe should work across browsers
# click ok to confirm
page.evaluate_script('window.confirm = function() { return true; }')

Verifying toasts using Appium , and get server reaction to button clicks

i'm new to android automation testing and i recently started to work with Appium.
I use it for android native app automation.
I have 2 question -
is there a way to verify toasts?
the latest posts i saw which referred to this issue are from the mid of 2014
and i wanted to know if there's something new in this subject before i will find another tool to run my tests with (as i understand selendroid can verify toasts).
is there a way to catch the http request which my app sends to the server when i'm pressing a button, during the automatic test?
something like a listener which works in the backround and wait for clicks?
tnx
To verify toast messages you can use one of image recognition libraries. For ruby I use RTesseract together with image processor RMgick
Idea is simple:
make toast message to appear
take few screenshots
iterate over taken screenshots and look for text
You may play with image processing, to increase recognition quality.
Here you can find code snippet which I use in my framework: link

How to verify redirection to Google Play Store

Using Robotium, how do I check the redirection to Google Play Store?
Steps:
Click on a link from a listview from the test app.
Verify it redirects to Google Play Store.
I noticed that while Google Play Store is open, my test app is actually open underneath also. (I printed out all the views)
Therefore, I cannot do "assert xyz view from test app does NOT exist".
How do I check the redirection to Google Play?
Is it possible? sort of, unfortunately robotium makes it very hard to do so easily, this is because of the way that robotium tracks what the current activity is, if you was using straight instrumentation it would be as easy as having an intent filter set up before you click the view/perform action that launches the play store, then you can assert that your filter has in fact been hit (which proves that the google play store would in fact be launched if you did not have the filter).
As you are using robotium though, you cannot do this so easily as robotium has already got an intent filter up that matches everything so this means you are going to have to do some horribleness with reflection.
What you will need to do is:
Get Hold of the private member of the instrumentation class called mActivityMonitors, in this list of activity monitors you will find there is one inside of it, this will be robotiums activity monitor, save this somewhere then remove it from the list.
You will then need to add your own it will look something like to test googleplay launches (i suggest reading about Intent filters on the android api documents site)
Instrumentation inst = getInstrumentation();
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_View);
ActivityMonitor monitor = inst.addMonitor(intentFilter, null, true); //true is imporant it blocks the activity from launching so that your test can continue.
assertEquals(0, monitor.getHits());
//do action that fires activity
assertEquals(1, monitor.getHits());
inst.removeMonitor(monitor);
You will now need to readd the activity monitor you removed earlier so that robotium continues to work as expected. I am not on a machine that i can actually test this all on but i have used this technique before.

WebKit Implementation with c#

I implemented webKit into a c# app i'm using and it works great except for one problem. Let me give a background of what i'm using it for.
This is a program i've been building that will run multiple tests on multiple customer accounts, it loads each test into it's own dynamically created browser controls and such. However the issue i'm having is that some of the tests use Iframes which pass information in between the parent and child pages. These Iframes run a few ajax commands that show that they are loading, however it doesn't finish executing whatever scripts it needs to run. Is there something i need to change in the way I've added WebKit to my application or anyone else that has had any similar problems? These tests work in chrome and safari as well so i know webkit can do it, but for some reason it's not doing it for me.
Thanks for the help!