Automating multiple applications with multiple Squish installations (iOS, Web)

Last edited on

Overview

The information below describes the setup for Squish for iOS and Squish for Web, but the instructions are not limited to these Squish editions, but apply to all/most editions of Squish.

Basic setup

Recording

Recording in the iOS application

Example recording:

def main():
    startApplication("iphonelauncher /Users/myuser/my_application.app")
    ctx_1 = waitForApplicationLaunch()
    clickObject(waitForObject(names.Text_Controls_UITableViewCell))
test.py

Recording in the Web application

Example recording:

def main():
    startBrowser("www.froglogic.de")
    clickLink(waitForObject(names.Customer_Login_A))
    clickLink(waitForObject(names.Squish_A))
test.py

This recording has to be integrated into the Squish for iOS test suite now, which is a simple copy & paste operation at first:

import names
def main():
    startApplication("iphonelauncher /Users/myuser/my_application.app")
    ctx_1 = waitForApplicationLaunch()
    clickObject(waitForObject(names.Text_Controls_UITableViewCell))

    startBrowser("www.froglogic.de")
    clickLink(waitForObject(names.Customer_Login_A))
    clickLink(waitForObject(names.Squish_A))
test.py

Then we add these lines (which are the equivalent of "startApplication()" but for the web browser):

testSettings.setWrappersForApplication("__squish__webhook", ["Web"])
ctx_web = startApplication("__squish__webhook", "localhost", 1234)

So the resulting script looks like this:

import names
def main():
    startApplication("iphonelauncher /Users/myuser/my_application.app")
    ctx_ios = waitForApplicationLaunch()
    clickObject(waitForObject(names.Text_Controls_UITableViewCell))

    testSettings.setWrappersForApplication("__squish__webhook", ["Web"])
    ctx_web = startApplication("__squish__webhook", "localhost", 1234)
    startBrowser("www.froglogic.de")
    clickLink(waitForObject(names.Customer_Login_A))
    clickLink(waitForObject(names.Squish_A))
test.py

As you can see we also modified one of the startApplication() lines and the waitForApplicationLaunch() lines to catch the return values, which are the application contexts of the iOS and web applications. We do this so that we are later able to switch between the application contexts, should it be required.

Replay

"<squish_for_web>/bin/squishserver" --verbose --port 1234

You can switch between application contexts via setApplicationContext():

import names
def main():
    startApplication("iphonelauncher /Users/myuser/my_application.app")
    ctx_ios = waitForApplicationLaunch()
    clickObject(waitForObject(names.Text_Controls_UITableViewCell))

    ...

    testSettings.setWrappersForApplication("__squish__webhook", ["Web"])
    ctx_web = startApplication("__squish__webhook", "localhost", 1234)

    ...

    setApplicationContext(ctx_ios)

    ...
test.py

Further information