Search code examples
xcodetestinginstrumentsui-automationios-ui-automation

UIAutomation with bwoken and tuneupJS


I'm trying to set up my UIAutomation using bwoken and tuneupJS. I followed the installation steps listed here, except I installed version 2.1.0rc.2 to get rid of the template path change in Xcode 6. Therefore my Gemfile looks like this:

# A sample Gemfile
source "https://rubygems.org"

# gem "rails"
gem 'bwoken', '2.1.0.rc.2'
gem 'cocoapods'

I have written a simple test just to see if I get anything to the console when I run it:

#import "../../../../Pods/tuneup_js/tuneup.js"

test("Example test", function(target, app) {
     var searchButton = target.frontMostApp().mainWindow().buttons()["Search Button"];
     assertTrue(searchButton.isValid(), "Search Button should be available on the screen");
     searchButton.tap();

     var saveSearchButton = target.frontMostApp().mainWindow().buttons()["Save"];
     assertTrue(saveSearchButton.isValid(), "Save Button should be available on the screen");
     saveSearchButton.tap();


     searchButton.tap();

     // tap on the background
     target.frontMostApp().mainWindow().buttons()[7].tap();


     searchButton.tap();
     saveSearchButton.tap();
     });

This is what I get back:

Building......................................................................
Build Successful!

iphone  FirstScript.js

ipad    FirstScript.js

The FirstScript.js is the test script I pasted. This doesn't look right, I'm assuming I should get more verbose output, just like the one in the example on the bwoken github page. So the question is: What am I missing here, where did I go wrong so my tests are not executed?

I also discovered some other problems when playing with bwoken:

  1. When I try to use --verbose flag, The only thing that happens is the build, there is no output indicating that any tests started.
  2. When I use --skip-build flag, it seems not to have any effect, the workspace is building anyway
  3. I miss some documentation on #github directive, namely how do I import the files that I get using #github? Where are they downloaded?

Edit: I tried to run the same directly with instruments command, it seems to work fine:

2014-11-17 16:08:00 +0000 Start: Example test 2014-11-17 16:08:01 +0000 Debug: target.frontMostApp().mainWindow().buttons()["Search Button"].tap() 2014-11-17 16:08:01 +0000 Debug: target.frontMostApp().mainWindow().buttons()["Save"].tap() 2014-11-17 16:08:01 +0000 Debug: target.frontMostApp().mainWindow().buttons()["Search Button"].tap() 2014-11-17 16:08:03 +0000 Debug: target.frontMostApp().mainWindow().buttons()[7].tap() 2014-11-17 16:08:03 +0000 Debug: target.frontMostApp().mainWindow().buttons()["Search Button"].tap() 2014-11-17 16:08:04 +0000 Debug: target.frontMostApp().mainWindow().buttons()["Save"].tap() 2014-11-17 16:08:04 +0000 Pass: Example test

Instruments Trace Complete (Duration : 7.199495s;

Output : /Users/me/Documents/Project/MyApp/instrumentscli8.trace)


Solution

  • I found similar issue in the bwoken GitHub repository issues section.

    What you need to do is to look up the available devices by doing:

    instruments -s
    

    this will print the list of available devices similar to this:

    Known Devices:
    Jakub’s MacBook Pro [FFBE27F6-3076-59B7-B14F-40E92F1366FD]
    iPad (7.1.2) [07056cc29131036c74d215ba52a9be605dc9e64a]
    Resizable iPad (8.1 Simulator) [26038DBD-791C-421E-99F4-9153CA726A2F]
    Resizable iPhone (8.1 Simulator) [31B2F0AE-3547-4189-A561-CD2088F6C645]
    iPad 2 (8.1 Simulator) [683233C4-EC2B-48A3-826B-10EF62A875CD]
    iPad Air (8.1 Simulator) [6358A6F5-2FD0-4377-BD32-0A2C3329276D]
    iPad Retina (8.1 Simulator) [224533ED-94DA-46CC-B1DB-1781A1C80710]
    iPhone 4s (8.1 Simulator) [D114BC7E-A913-4063-A349-C119BAFC06DA]
    iPhone 5 (8.1 Simulator) [7AF6D6F4-C6BC-4A47-B83C-3A4B43ABE0DD]
    iPhone 5s (8.1 Simulator) [BE82D607-466A-43E5-863D-6A05F217C117]
    iPhone 6 (8.1 Simulator) [D183FF05-3023-4FB5-BEA0-290EA881040A]
    iPhone 6 Plus (8.1 Simulator) [0AFCC9AB-7C59-48C7-9BFB-FBF4865B7A63]
    

    Note the MacBook Pro being the first entry, which allegedly is the root problem here. Now, you can work around it by calling:

    bwoken test --device D183FF05-3023-4FB5-BEA0-290EA881040A
    

    I hope this helps somebody.