Navigation commands

List of commands

Command Description
I.goTo Navigate to a URL
I.refreshPage Refresh the page
I.switchTab Switch to the next tab
I.closeTab Close the current tab

Page assertion commands

Command Description
I.amAt Assert that the browser is at a specific URL

I.goTo

Navigate to a URL.

Usage

I.goTo(url);
I.goTo(url, options);
Parameters
Parameter Type Remarks
url string URL to navigate to.

You can use an absolute URL like http://mystore.com/shoes or a relative URL like /shoes.

If there is Basic HTTP Authentication on the page, add the username and password to your url like this: https://username:password@mystore.com
options object See below.
Options
Option Type Remarks
newTab boolean Flag to open the url in an new tab. Defaults to false

Example(s)

Absolute URL
I.goTo("https://mystore.com/shoes");

Go to https://mystore.com/shoes.

Absolute URL with Basic HTTP Authentication
I.goTo("https://username:password@mystore.com/shoes");

Go to https://mystore.com/shoes.

Relative URL
I.goTo("/shoes");

Go to the "/shoes" path of the current domain.

The following table shows where the browser will be navigated to depending on the current URL:

Before After
https://storeA.com https://storeA.com/shoes
https://storeB.com https://storeB.com/shoes
https://mystore.com/wallet https://mystore.com/shoes
Query string
I.goTo("?color=blue")

Set the query string of the URL to 'color=blue'.

The following table shows where the browser will be navigated to depending on the current URL:

Before After
https://mystore.com/shoes https://mystore.com/shoes?color=blue
https://mystore.com/shoes?color=red https://mystore.com/shoes?color=blue
Hash
I.goTo("#sale")

Set the hash of the url to 'sale'.

The following table shows where the browser will be navigated to depending on the current URL:

Before After
https://mystore.com/shoes https://mystore.com/shoes#sale
https://mystore.com/shoes#new https://mystore.com/shoes#sale
Open in a new tab
I.goTo("https://mystore.com", {newTab: true})

Set newTab option to true to open "https://mystore.com" in a new tab.


I.amAt

Asserts that the browser is at a specific URL.

You can use an absolute URL or a relative URL.

Usage

I.amAt(url)
Parameters
Parameter Type Remarks
url string URL to check against

Example(s)

Absolute URL
I.amAt("http://mystore.com")

Matches the following:

Does not match:

Without protocol
I.amAt("://mystore.com")

Matches the following:

Relative URL
I.amAt("/shoes")

Matches the following:

Query string
I.amAt("?color=blue")

Matches the following:

Does not matches:

Hash
I.amAt("#sale")

Matches the following:

Does not matches:


I.refreshPage

Refreshes the page

Usage

I.refreshPage()

I.switchTab

Switch to a tab.

Usage

I.switchTab() // switch to the next tab
I.switchTab(tab) // switch to a specific tab by tab number or page title
Parameters
Parameter Type Remarks
tab number or string (Optional)
Tab number or page title to switch to.
If not provided, switch to the next tab.

Example(s)

Switch to next tab
I.switchTab()

Switch to the next tab.

If the browser is currently on the last tab, then this command will switch to the first tab.

Switch to tab with tab number
I.switchTab(2)

Switch to the second tab.

Switch to tab with page title
I.switchTab("Login") // switch to the next tab

Switch to the tab titled "Login".


I.closeTab

Close the current tab.

I.closeTab cannot be used if there's only one tab open.

After the tab is closed, the browser will be automatically switched to the next tab (or the last tab if the closed tab was the last).

Usage

I.closeTab()