Monday, July 15, 2013

Calabash-ios on Windows

In the last post I discussed about setting up the Mac environment for running Calabash-ios tests from Xamarin studio. In Mac, we can run the calabash-tests on simulator easily by using the Fast Track steps if using Xcode or by using these steps if using Xamarin studio. To run on a device in mac we need to identify the device ip address  and use it in the terminal like this

DEVICE_ENDPOINT=http://192.168.1.146:37265 NO_LAUNCH=1 calabash-ios console

NO_LAUNCH=1 disables the simulator launch. Now if you launch the app in the device and run queries in the terminal it would work.

Running tests on Windows machine

On Windows machine we can run tests only on device and not on simulator(couldnt find a simulator for ios on windows yet).  You can setup Calabash framework on windows using gem install as specified in the calabash ios github wiki page.

Since we cannot build the Xamarin ios project completely on windows without a mac host, we assume that we have a .ipa file built from Mac setup which has the Calabash-framework force loaded. Copy the .ipa file built from Mac to Windows machine where you want to run tests. Connect the device to your windows machine and then open the .ipa file using itunes. It will list the app(say MyApp) under Apps category in itunes and then you can drag and copy it to the device(your device would be listed in the side pane and when you drag the app it will show the connected device and you can drop on the device name and it would install in device). Then you should be able to launch the app in the device and it would also have started the calabash-server. 
And , if you are following the cucumber.yml file(as mentioned in field-service-example), you can modify the ios profile like this,

ios: DEVICE_ENDPOINT=http://[ipofdevice]:37265 NO_LAUNCH=1 DEVICE=[udid] CALABASH_FULL_CONSOLE_OUTPUT=TRUE NO_STOP=1 OS=ios6 PLATFORM=ios -r features/support -r features/ios/support -r features/ios/helpers -r features/step_definitions -r features/ios/pages

and then in command prompt you can run something like(for login feature) cucumber -p ios features/login.feature .

NOTE: I haven't yet figured out how to use the bundle id and have the tests automatically start the app in device yet and if i do so, I will either update this post or enter a new blog to keep track of it.

Happy Testing :)

7 comments:

  1. Hi, did you ever get this working? I modified the ios profile to match what you said above (editing my details within it)...

    But when I run cucumber -p ios features/registration.feature I get the following error:

    Retrying.. Errno::ECONNREFUSED: (No connection could be made because the target machine actively refused it. - connect(2) (http://10.53.4.51:37265))

    ReplyDelete
  2. BTW, I'm trying to get my .ipa file to run on my Windows machine... It's been signed with the calabash.framework on a Mac before hand..

    ReplyDelete
  3. Yes, I did have it working when I wrote this post. No connection error indicates that the calabash server is not running on the app. Can you try running it on your mac(with simulator or device) using Xcode(or xamarin if using mono) and see if you get the message in console indicating server started.

    ReplyDelete
  4. Hi,
    Can't we run our scripts without .ips file on Windows machine.

    ReplyDelete
  5. No, its not possible to run on windows without the .ipa file(AFAIK)

    ReplyDelete
  6. Thanks for the post. Helped us to start execution, but not facing below issues

    1. Unable to open console
    when i try to open console through "DEVICE_ENDPOINT=http://192.168.1.179:37265 calabash-ios console" getting an error "'DEVICE_ENDPOINT' is not recognized as an internal or external command, operable program or batch file."

    2. Not able to perform any actions like touch, keyboard_enter... etc

    My Environment:
    Calabash-cucumber 0.1.168, ruby 1.9.3p448, iPhone 5 running on iOS 7.1

    Please provide any insights to resolve the issue(s).

    Thanks in advance,
    Satya

    ReplyDelete
  7. Does anybody ever get it working except for author of this post?

    ReplyDelete