Assert SQL in Content

This command is not part of the Default Command Set. You have to register the SQL Command Set first (see Configuration).

Executes the given SQL query against the configured database and asserts that all returned values appear in the current page content.
This is useful to verify that data from the database is correctly displayed in the application's UI. Null column values are ignored.

Parameters

sql-query
The SQL SELECT statement to execute (required).
To target a specific database connection, prefix the SQL with '@[db-name] ', e.g. '@mydb SELECT ...'. If no prefix is given, the default connection is used.
timeout
An optional timeout in seconds.
If specified, Wetator will wait up to this number of seconds for the page content to match. Useful for pages that load data asynchronously.

Examples

Config (wetator.config)
wetator.commandSets=org.wetator.commandset.SqlCommandSet
wetator.db.connections=mydb
wetator.db.mydb.driver=org.hsqldb.jdbcDriver
wetator.db.mydb.url=jdbc:hsqldb:mem:testdb
wetator.db.mydb.user=sa
wetator.db.mydb.password=

Assert that all user names from the database are shown on the current page

Command Parameter Optional Parameter
open-url users/list
assert-sql-in-content SELECT name FROM users ORDER BY id