Automating multiple applications with multiple Squish installations or editions (Qt, Web)

Last edited on

Overview

Using multiple Squish editions in a single test script is possible and this article describes an example setup and work-flows for this utilizing Squish for Qt and Squish for Web, but these instructions generally apply to any combination of Squish editions used in a single test script.

Basic setup

Recording

Recording in the Qt application

Example recording:

def main():
    startApplication("addressbook")
    clickButton(names.address_Book_New_QToolButton)
test.py

Recording in the Web application

Example recording:

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

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

def main():
    startApplication("addressbook")
    clickButton(":New Project_QToolButton")

    startBrowser("www.froglogic.com")
    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:

def main():
    ctx_qt = startApplication("addressbook")
    clickButton(names.address_Book_New_QToolButton)

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

As you can see we also modified the startApplication() lines to catch the return values, which are the application context of the Qt and web applications. With these application contexts we can switch between automating each application, should it be required, by using the setApplicationContext() function.

The entries from the scripted object map of the Web test suite must be copied to the scripted object map of the Qt testsuite, otherwise Lookups in the object map will fail for the symbolic names recorded for the Web part.

Replay

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

You can switch between application contexts via setApplicationContext():

def main():
    ctx_qt = startApplication("myqtapp")

    ...

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

    ...

    setApplicationContext(ctx_qt)

    ...
test.py

Further information

Recording on other applications

Application Context

How to Test Multiple AUTs from a Single Test Script, Using ApplicationContext

How to Use ApplicationContext Objects

setApplicationContext()

currentApplicationContext()

applicationContextList()