Many developers use puppeteer to execute automated UI tests. However puppeteer is just a software to control Chromium and it is impossible to provide some assertion methods.
Rize provides a lot of useful assertion methods for testing. Rize is just a library and it use Node.js'
assert module so you can use Rize with any testing frameworks you like.
Asserting page information
You may want to assert the URL of current page, so you can use
If you want to check the URL is matched a given regular expression, use
Also, you can assert the query string. Just use
You may want to check the query string value and not just the key:
The assertion above means check the value of
key in query string. If the value does not equal to the value you gave, test will fail.
Even you can assert the query string misses a key:
Additionally, if you want to assert cookies, you can use
Asserting page content and elements
If you want to check if the page contains expected text, just use
You also can use
assertSeeIn method to assert that expected text is in an element, and you just need to specify the selector of the element.
You can assert the state of an element:
rize.assertElementPresent('div') rize.assertElementMissing('div') rize.assertElementVisible('div') rize.assertElementHidden('div')
You can check if an element contains a class:
Or missing a class:
You can assert the state of a checkbox, a radio button or a dropdown:
rize.assertChecked('input[type=checkbox]') rize.assertNotChecked('input[type=checkbox]') rize.assertRadioSelected('input[type=radio]', 'south') rize.assertRadioNotSelected('input[type=radio]', 'north')
All the assertion APIs of Rize are listed here. Those methods are prefixed with