05/15/2017 Featured Christopher Reichert

In this post, I will illustrate 3 simple examples for testing an HTML website using Assertible. The examples described in this post are perfect for continuously smoke-testing your site from a continuous integration pipeline or deploy script.

These examples assume you have an Assertible account with a valid web service and test. If you don't have a web service, just click here.

Assertible is free to use if you need an account.

1. Validate HTML structure

The most fundamental way to test an HTML website in Assertible is to check that the HTML is valid. This can be done using the HTML validation assertion. The HTML validation assertion utilizes the W3C HTML Validation and is a robust way to check markup while also delivering fine-grained valuable error messages.

From the Assertible dashboard, navigate to (or create) a test, and click the Assertions configuration tab. In the Assertion type drop-down, select HTML Validation

HTML validation assertion configuration

This assertion does not take any input. If the assertion fails, you will recieve detailed information about the nature and location of the validation error.

HTML validation failure result error message

Another fundamental way to test an HTML website is to ensure all links on a document are valid. In many cases, users of your website may never tell you that links are broken and will simply leave.

Broken links are very simple to check in Assertion using our Link check assertion. The Link check assertion tests the following elements:

  • <a>
  • <script>
  • <link>
  • <img>

From the Assertible dashboard, navigate to (or create) a test, and click the Assertions configuration tab. In the Assertion type drop-down, select Link check

Link check assertion configuration

The link checker does not need any input configuration. If the assertion fails, you will recieve detailed information about the structure of the error

Link check assertion failure result error message

3. Check for specific HTML elements

In many test scenarios, it's important to check that specific HTML elements exist on a served page. For example:

  • Validating page titles
  • Validating DOM element exists
  • Validating CSS classes

From the Assertible dashboard, navigate to (or create) a test, and click the Assertions configuration tab. In the Assertion type drop-down, select Assert text body.

Text body assertion configuration

The Assert text body configuration takes two inputs:

  • Comparison This drop-down only takes the value contains although we plan to expand to more comparisons
  • Target value This is the text you wish to ensure exists on the page

Once you have finalized your assertion configuration, click Save assertion. If the assertion fails, you will recieve detailed information about the structure of the error

Text body assertion configuration

More test cases

The 3 assertions described in this post can ensure a large percentage of common errors are dealt with. The value in using Assertible to test these failure scenarios is that you can automate the checks from your continuous integration pipeline or deploy script to continuously test your website.

Because Assertible supports multiple assertions per test, we highly recommend combining the HTML validation and Link check assertions with other types of assertions, such as:

  • test POSTing a form
  • check that a user can log-in and log-out
  • check that all Javascript and CSS assets are included on a page

These can all be combined into a single test:

HTML page assertion configuration


Get started testing your HTML website now!
Assertible is free to use. Contact us if you have any questions or feedback!


More docs (who doesn't love docs?):

Is there an assertion or feature you'd like to see? Send us a message or reach out on Twitter and let's talk!

:: Christopher Reichert

Categories

Automate your QA pipeline

Define and test your web service with Assertible Track and test API deployments across environments Schedule API monitoring and failure alerts

Reduce bugs in web applications by using Assertible to create an automated QA pipeline that helps you catch failures & ship code faster.

Sign up for free