URL assertions

A URL assertion can confirm that your test is on the right web page during test execution. Some examples of use cases for URL assertions include:

  • After clicking on a link, asserting that the test has navigated to the new URL
  • Asserting that a certain ID that shows up on a page matches the ID in the URL

Creating a URL assertion

Navigate to a test in which you'd like to add the assertion, and ensure that the browser is in the desired state.

  1. Click on the check mark icon at the bottom of the mabl Trainer window.
  2. Select URL assertion.
  3. Configure the assertion in the URL assertion menu. (You can find an explanation of URL attributes and properties in the following section.)
  4. Click OK.


If you expect to see the login page after logging out of an application, and the URL was {{@app.url}}/login, you could assert that the pathname equals /login.


URL attributes and properties

You can create URL assertions against a number of attributes and properties of the URL. These include the hash, host, hostname, href, password, pathname, port, protocol, search, and username. URL assertions select the "pathname" attribute by default. More information about these can be found here, or summarized below.


The hash property sets or returns the anchor part of a URL, which includes the hash sign (#). For example, #sailingboat is the anchor part of the https://www.example.org/index.html#sailingboat URL.


The host property sets or returns the hostname and port of a URL. "Host" includes the port number if specified. If there's no port number specified in the URL, then it returns the same as the hostname. For example, "hostname" might provide "example.org" but host returns "example.org:7777".


The href is an attribute of the anchor tag, and specifies the URL of the page that a link goes to. If there's no href attribute, then the link is not a hyperlink.


A URL setting can sometimes include settings for user and password.


This attribute is selected by default. The pathname property sets or returns the pathname of the URL.


The port property sets or returns the port number that the server uses for a particular URL.


The protocol property sets or returns the protocol of the URL, which includes the colon (:)


The search property sets or returns the query-string section of a URL, which includes the question mark (?).


The username property sets or returns the username section of the href attribute value. The username is entered by the user, and is specified after the protocol but before the password.

Attribute/property dropdown open showing what parts of a URL you can create assertions against.

Attribute/property dropdown open showing what parts of a URL you can create assertions against.


Running assertion steps

All find actions in mabl, including URL assertions, will automatically wait up to 30 seconds for the targeted element to appear. There is generally no need to add an additional wait step before an assertion, unless the URL takes more than 30 seconds to appear. If this is the case, a wait step before the assertion may be necessary. Find more information about wait steps in mabl at our "Adding wait steps with the mabl trainer" doc.