Big news! The community will be moving to a new platform April 21. Read more.
Big news! The community will be moving to a new platform April 21. Read more.

GUI Test Scripting in Python

GUI Test Scripting in Python

This is a quick introduction into implementing GUI test scripts in Python. These test scripts are not compiled and can be processed from scratch. To create or adapt a script you only need a text editor. To drive an application, the Java Testing Framework (JTF) API of Silk Test is used. The following example script opens a web browser, navigates to Google, starts a search and clicks onto a specific link:

from com.borland.silktest.jtf import Desktop
from com.borland.silktest.jtf import BrowserBaseState
from com.borland.silktest.jtf.xbrowser import BrowserWindow
from com.borland.silktest.jtf.xbrowser import DomTextField
from com.borland.silktest.jtf.xbrowser import DomLink

desktop = Desktop()

def start_browser():
    baseState = BrowserBaseState("%ProgramFiles%\\Internet Explorer\\iexplore.exe", "about:blank", [])

def test_google_MF_products():
    # find the BrowserWindow object and navigate to Google
    browserWindow = desktop.find("/BrowserApplication//BrowserWindow")
    # find the search input DomTextField object, type the lookup text and ENTER
    # find the MF-Products DomLink object and select it
    browserWindow.find("//A[@textContents='Products - Micro Focus']").select()


The Silk Test Recorder can be used to record a JTF script, which is a Java source file. You can easily adapt parts of the Java code to Python. The recorder also generates the locators that are used to identify the GUI objects to be processed. If you are familiar with the JTF API, you can also use the recorder to pick the needed locators from the GUI of an application.

Installation Steps

  1. Install Silk Test
    Intranet: GA Product Listing Link
    Web: Silk Product Trials
  2. Install the latest version of Jython
    Jython Download Link
  3. Set or extend the CLASSPATH environment variable to include the JTF jar file:
    SET CLASSPATH=…;C:\Program Files (x86)\Silk\SilkTest\ng\JTF\silktest-jtf-nodeps.jar
  4. Extend the PATH environment variable to include the Jython binary folder, default path for version 2.5.2 is:
    SET PATH=…;C:\jython2.5.2\bin
  5. Copy and paste the script from above, for example into the file ‘’, open a cmd shell window and execute the script:
    C:\myscripts> jython

The JTF API documentation is located as javadoc in the JTF jar file. Open the jar file with a ZIP tool, extract the folder /javadoc to your local file system and open the index.html in a browser. Since SilkTest 2010 R2 WS2 you find also a shortcut in the Windows start menu: Silk > SilkTest 2010 R2 WS2 > Documentation > Silk4J API Reference

You can use any Java scripting language to utilize JTF to drive GUIs, for example JRuby, Java Tcl, Rhino, BeanShell, Scala, Groovy and others.

Silk Test Links

Labels (1)


Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.

Can this procedure be adopted if using Robot framework for ATDD?

Yes, that should work as long as Robot is running on Jython. See also the Robot installation document, section "Preconditions":

Top Contributors
Version history
Revision #:
2 of 2
Last update:
‎2020-03-11 17:34
Updated by:
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.