Automating Google Chrome Apps on Windows

Last edited on

Overview

Squish for Windows can automate Google Chrome Apps on Windows via its UI Automation extension, which taps into the UI Automation accessibility support in Google Chrome - if the latter is enabled.

Because UI Automation support is by default disabled in Google Chrome (and therefore for Google Chrome Apps) it must be explicitly enabled by passing the parameter "--force-renderer-accessibility" to chrome.exe. To make this is a bit easier it is best to use a simple .bat file as AUT in Squish.

Required Steps

Step 1 - Create chrome_app_launcher.bat which starts Google Chrome's App Launcher

This only needs to be done one time.

:: "chrome.exe" must not be already running, so close
:: it first:
taskkill /f /im chrome.exe

:: Adjust this path to "chrome.exe" as required:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --force-renderer-accessibility --show-app-list

:: This exit command is required to ensure that the associated
:: cmd.exe process gets closed:
exit
chrome_app_launcher.bat

Step 2 - Select chrome_app_launcher.bat as AUT in Test suite settings

This only needs to be done one time.

Step 3 - Configure Squish's UI Automation extension to take precedence over other extensions

This only needs to be done one time, but should be done in a separate Squish for Windows package, because it alters the package configuration.

In file squish_dir/etc/extensions/win/uiautomation.ext change the priority in entry...

<priority>-10</priority>

...to...

<priority>100</priority>

Step 4 - Recording & Replay

Now it should be possible record and replay on any Google Chrome App.

Example Test Script

Here is an example script recorded on the " Calculator " Chrome App by "Aidan":

# -*- coding: utf-8 -*-

import names

def main():
    startApplication("chrome_app_launcher.bat")
    type(waitForObject(names._Edit), "calculator")
    type(waitForObject(names._Edit), "<Return>")
    clickButton(waitForObject(names.1_Button))
    clickButton(waitForObject(names.+_Button))
    clickButton(waitForObject(names.1_Button))
    clickButton(waitForObject(names.=_Button))
    mouseClick(waitForObject(names.1+1=_Label), 11, 2, MouseButton.PrimaryButton)
test.py

Note that the two commands after startApplication() are responsible for typing the name of the Chrome App that should be started.

(Please note that this script only serves for demonstrating the ability to record on Google Chrome Apps. Replaying this test script requires an names.py file with the symbolic names used in the script above. Also see Article - How Squish looks up Real Names from Symbolic Names .)