Wednesday, 11 December 2013

XCode UIAutomation - Why no recursive search?

OK, I love that Apple support a UI automated testing without having to add custom hooks into your app.

I also love the efforts by projects such as Appium to enable cross platform testing using any test framework you like (eg: Cucumber Ruby for me).

But why oh why must Apple require us to traverse complex hierarchy of elements (which may change) to find the element we want to test? Why no simple withPredicateRecursive(..) ?? That would make our lives much easier!

I spent a while expecting surely there is a way, but couldn't find it.

The simplest way was suggested in the book Test iOS Apps with UI Automation: Bug Hunting Made Easy which is to make a javascript function to recursively search the hierarchy.

Here is how (taken from the books publicly available sample code):

 function recursiveSearch(predicate, startElement) {
            target.pushTimeout(0);
            // ...

            var elements = startElement.elements();
            var found = elements.firstWithPredicate(predicate);
            target.popTimeout();

            if (found.isValid()) return found;

            for (var i = 0; i < elements.length; i++) {
                var element = elements[i];
                found = recursiveSearch(predicate, element);
                if (found) return found;
            }

            return null;
        }

Use it like this:


var add_button = recursiveSearch("name matches 'Add'", 
UIATarget.localTarget().frontMostApp().mainWindow());

Thursday, 5 December 2013

Capture 360-degree video with DLSRs and GoPros, viewable on an Oculus Rift


http://www.kickstarter.com/projects/95342015/360o-for-gopro-dslr-video-and-compact-cameras-ocul

I've been wanting to do this project for a while. Particularly around streaming sporting events / concerts to people wearing the VR headsets.

Anyone want to do this?