Assume you already worked with calabash-ios for some time, but now you wonder how calabash do the job and what is underlying the cucumber code?
First layer: UIA functions:
Go to open “calabash-cucumber” gem and you will find this file: uia.rb, in this file there are uia_* methods. You can use those methods to simulate touch swipe and keyboard type on connected physical devices.
what are uia_functions? UIA mean UIAutomation which is a xcode instrument. You can think them as “official api for interacting with IOS”, here is the link, and also another link for more detailed reference.
Lets use this method as the example: uia_tap_mark()
def uia_tap_mark(mark)
uia_handle_command(:tapMark, mark)
end
Now the question is how calabash-ios send the uia command to ios and run it?
Second layer: uia-scripts
There comes the calabash-script, you can download it from calabash github repo. I am still tying to figure out how calabash-cucumber interact with calabash-script, but before that, we still can take a look at what is inside calabash-script.
The definition for tabMark is as below:
(defn tap-mark
[mark]
(tap [:view {:marked mark}]))
Basically, calabash-script translate the calabash uia commands to UI Automation commands. Read this:
CalabashScript is a ClojureScript library for writing automated
functional tests for native iOS Apps.
CalabashScript provides friendly ClojureScript APIs based on
the (perhaps not so friendly) UIAutomation APIs.
Third layer:
UI Automation (native ios api)