Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.

Can SilkTest compare information from a GUI with the data in it"s database?

Can SilkTest compare information from a GUI with the data in it"s database?

SilkTest is a functional testing tool that interacts with Graphical User Interfaces (GUIs) however it can also handle data being passed to and from databases. This can be done via the use of database testing functions in SilkTest, please refer to the SilkTest help for an updated list of all such functions.

In the below example we are capturing information from the GMO sample application and comparing the data with the data held in the GMO database.

[-] testcase DBTest ()
 [ ] LIST OF STRING lsName, lsNameDataB
 [ ] STRING slastFirst
 [ ] INTEGER i = 0
 [ ]
 [ ] CustomerInformation.SetActive ()
 [ ] CustomerInformation.DialogBox1.Search.Click ()
 [ ] CustomerSearch.SetActive ()
 [ ] lsName = CustomerSearch.Customers.GetContents() // get all the customer names from the application
 [ ]
 [ ] STRING iNum, iheadID
 [ ] STRING sFirstName , sLastName
 [ ] HDATABASE hdbc
 [ ] HSQL hstmnt
 [ ]
 [ ] // connect to green mountain db
 [ ] hdbc = DB_Connect ("dsn=green2;PWD=;UID=")
 [ ] // retrieve info from table
 [ ] hstmnt = DB_ExecuteSql (hdbc, "SELECT * FROM cidb")
 [ ]
 [-] while (DB_FetchNext (hstmnt, iNum, sFirstName, sLastName)) // get all the customer names from the DB
  [ ] slastFirst = sLastName +", "+sFirstName // Get the names into the same format as that returned from the application i.e lastname, firstname
  [ ] ListAppend (lsNameDataB, slastFirst ) // Add names to the list
 [ ]
 [ ] //Verify the list returned from the DB is the same size as that from the Application
 [ ] INTEGER iDatasize = ListCount (lsNameDataB)
 [ ] INTEGER iAppsize = ListCount (lsName)
 [ ]
 [-] if (iDatasize != iAppsize)// ensure the same amount of names are returned from the database and the application
  [ ] print ( "There are not the same amount of names in the database then there are in the Application")
 [ ]
 [-] for(i=1;i<ListCount(lsNameDataB);i++)
  [-] if (lsNameDataB == lsName) // Are the values in both lists the same
   [ ] Print ( "Database and application both contain " + lsNameDataB )
   [ ] Print ()
 [ ]
 [ ] // disconnect from the database
 [ ] DB_Disconnect (hdbc)



Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 19:35
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.