Navigation examples
Opening a page
The open
command navigates to the URL specified. For example, let's open the Google homepage:
open http://google.com
Clicking a link
There are several ways to identify and click a link in a page. The most convenient one is by text content. This example clicks a link with the text "Register now"
<a href="/register">Register now</a>
click "Register now"
Alternatively, you can use the CSS attribute selector to target the link with the correct destination:
click [href="/register"]
Finally, you can always use any other CSS selector to target elements:
click .main-nav-home
click #logo
click .main-menu li:first-child > a
Going back or forward in history
The back
and forward
actions go back or forward one step in history.
back
Checking the location
There are two ways to check we're currently at the correct location. The easiest is assertPage
, which checks if the argument is a substring of the current URL.
assertPage /home.html
Combined example
Here's a combined example that follows and checks some links on reddit.com:
open http://reddit.com click "new" assertPage /new click "rising" assertPage /rising back assertPage /new