Assert Content
Asserts that the current page contains the expected content.
Parameters
It is possible to use the '*' and the '?' character as wildcards; '*' matches zero or many characters; '?' matches one single character.
It is also possible to define a comma separated list of words (with '*' and '?' if needed). Then this command checks, that the words in the defined order are parts of the content.
At the moment content of type text, html/xhtml, pdf, rtf, xls, xlsx and docx are supported.
Examples
Check for a single word on a page
Check for a single word on a page.
| Command | Parameter | Optional Parameter | |
|---|---|---|---|
| open-url | commands/openurl.html | ||
| assert-content | Gurkensalat |
Check for a single word using wildcards on a page
Check for a single word using wildcards on a page.
| Command | Parameter | Optional Parameter | |
|---|---|---|---|
| open-url | commands/openurl.html | ||
| assert-content | Gu*sa?at |
Check for words in the right order on a page
Check for words in the right order on a page.
| Command | Parameter | Optional Parameter | |
|---|---|---|---|
| open-url | commands/openurl.html | ||
| assert-content | Pferde, keinen, Gu*sa?at |
Content checking for common file formats (PDF, RTF, xls, xlsx and docx)
The 'assert-content' command works with HTML pages and also supports common file formats. If your application offers the ability to download e.g. PDF files, you can simply write tests for the correct content also. To make this happen the file has to sent out by the server with the correct (supported) content type. At the moment the following content types are supported:
| Type | Content-Type Header |
|---|---|
| application/pdf | |
| MS Excel (xls, xlsx) | application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
| MS Word (docx) | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
| RTF | application/rtf,text/rtf,text/richtext,text/enriched |
Check the content of a PDF file.
If your application allows downloading a PDF, use 'open-url' to navigate to the PDF and then 'assert-content' to verify its text content.
| Command | Parameter | Optional Parameter | |
|---|---|---|---|
| open-url | reports/invoice.pdf | ||
| assert-content | Invoice No., Total Amount |
