title | description | tags |
---|---|---|
Validate URL |
Learn how to use the I.amAt command to validate a URL in your UIlicious test. |
i.amat, page navigation, url |
Use the I.amAt
command to validate the url of the current tab.
Set the url that you want to check as the first argument. The URL should be enclosed in quotes.
This command will fail the test if the URL of the current tab does not match the expected URL.
{% tabs %}
{% tab title="Example" %}
I.goTo("https://google.com")
I.amAt("https://google.com") // this should pass
{% endtab %}
{% tab title="Result" %}
<iframe title='i-am-at-example-1' src="https://snippet.uilicious.com/embed/test/public/34qeVUNWueXA1PjQWGJ3iH?stepNum=2&autoplay=0" style="display: block; min-width: 600px; min-height: 400px; margin: 0 auto; border: none;"></iframe> {% endtab %}{% endtabs %}
You can specify parts of the URL to validate instead of the full path. The I.amAt
command will split and validate the URL into the followin parts:
- Protocol, e.g,:
http
,https
- Domain, e.g.:
myapp.com
oruat.myapp.com
- Path, e.g.:
/books/mystery
- Query String, e.g.
?search=history
- Hash, e.g.
#popular
If you want validate the domain but ignore the protocol, start with ://
.
// this should pass for:
// "http://google.com"
// "https://google.com"
I.amAt("://google.com")
If you want validate the path, but ignore the protocol and domain, start with /
followed by the path.
// this should pass for:
// "https://mystore.com/books/mystery"
// "https://uat.mystore.com/books/mystery"
I.amAt("/books/mystery")
Include ?param=value
to validate the query string in the current URL.
// this should pass for:
// "https://mystore.com?search=alice in wonderland"
I.amAt("?search=alice in wonderland")
Include #hash
to validate the hash in the current URL.
// this should pass for:
// "https://mystore.com#popular"
I.amAt("#popular")
Usage
I.amAt(url)
Parameters
Parameter | Type | Remarks |
---|---|---|
url | string | URL to check against |