Purpose
Generate and compare a series of SAP GUI screenshots

Generating screenshots automatically is useful both for documentation purposes and for building test tools. Here we describe how you can run InputScripts which generate a series of screenshots, saving the image files and comparing the newly generated screenshots with older ones. We automatically produce "delta" images that show which screen parts have changed.

Given a stable set of test data such as customer master data, orders, equipment and so on, you can use this approach to detect any changes of the visible data or of the screen layout after installing a new SAP GUI patch, GuiXT version, SAP kernel, SAP application release, Windows version or after any changes you have made in SAP customizing.

You may also include your GuiXT scripts in your tests so that you automatically detect the screens that now look different, due, for example, to a new SAP field on one of the screens after implementing a new SAP package.

Remarks
The approach is easy to implement and to use,  but it has its limitations. Please observe:

  • You need to carry out the tests with the same SAP theme and font settings. Or you use separate sets of screenshots for different SAP themes and font sizes.
  • When you include "change" transactions, do the reverse operation in the same InputScript so that you can re-run the script and obtain the same data.
  • In some cases the current date is shown on an SAP screen. Use a GuiXT "del" command for this field so that it will not appear on the screenshot. Or a "pos" command which moves the field to a position outside of the visible SAP GUI screen.
  • When you run a transaction that creates a new object, for example a new maintenance order, the final SAP message is different each time you run the script, since the message contains the new order number. You can simply omit this final screen in the screenshot generation or you send your own message without the new document number, using a "message" command in the script.
  • When a test script starts, the SAP GUI window is automatically resized to 1280x1024 so that the generated screenshots can be compared easily. This window size is configurable, but if you change it you invalidate previous screenshots.
  • The scripts are run in a visible mode. You need to keep your mouse outside of the SAP GUI window while the script is running, otherwise small changes in the screenshots will occur, for example a pushbutton will receive the focus.
    We could shift the SAP GUI window to an invisible part of the screen while the test script is running - in the same way as we change the window size -, but we do not recommend this since it is easier to keep the control when you run the scripts and see what is going on.
  • User parameters and input in previous screens may lead to different screen output. We suggest you logon with a special user with well-defined and stable user parameters.
  • There is no limitation on the number of steps executed by the script, but we suggest you keep it below around 20 steps and cover your transactions and screens by several scripts instead of a single large one.
  • Optionally you can implement your own test cockpit, consisting of one pushbutton for each script and maybe an overview on previous runs and their results.

There is much room for enhancements, but even a very simple and easy to implement version with say 12 test scripts can save you a lot of time.

Prerequisites

  • GuiXT version 2018 Q2 1 or above
  • For an easy start copy our framework scripts veriscripts.zip into your script folder
  • The "delta" gif generation is performed via the "magick" imaging tools (open source). You need to install the tools on the PC where you run the test scripts. They are available free of charge at https://www.imagemagick.org/script/download.php

Video


Show video in full screen

Download framework scripts (includes VB.NET dll and source)

 

Framework scripts

The framework scripts are contained in the linked zip file (above). Feel free to adapt the folder names to your needs.

 

GuiXT script "verify_header.txt"

// folder name
Set V[verify_dirnew] "C:\verification\test.&V[today_y-m-d hm]"

// verified screenshots
Set V[verify_dirver] "C:\verification\verified"

// error folder
Set V[verify_direrr] "C:\verification\error.&V[today_y-m-d hm]"

// Initialize error count
Set V[verify_errorcount] 0

// Initialize verify counter
Set V[verify_counter] 0

// SAP Easy Access
Screen SAPLSMTR_NAVIGATION.0100
del X[IMAGE_CONTAINER]

  Image      (9.2,5.4) (15.7,87.2)  "white.res" _
       
-plain   -transparent  _
        
textstring="Please move mouse out of SAP GUI window\nVerification starts" _
        
textHeight=34 textFont="Tahoma" textColor="RGB(255,128,64)"

  Enter "/0" -visible  wait=3000

Screen SAPLSMTR_NAVIGATION.0100

// resize SAP GUI so that screenshots become comparable
CallVBAsync verify.utilities.sapgui_set_windowsize 1280 1024

Enter

 

GuiXT script "verify_screen.txt"

Set V[verify_counter] &V[verify_counter] + 1

CallVBAsync verify.utilities.verify_screen _
  
"&V[verify_dirnew]" _
  
"&V[verify_dirver]" _
  
"&V[verify_direrr]" _
  
"&V[verify_id].&V[verify_counter]"

  

GuiXT script "verify_footer.txt"

Screen SAPLSMTR_NAVIGATION.0100 

  // display result
 
Message "&V[verify_errorcount] errors" -statusline

  Enter

 

Sample test cockpit (used internally for GuiXT regression testing)

Components
InputAssistant+Controls