Finding images on page 17/05/2013
# Finding all images on a page
browser.images

# Finding images inside of an element
browser.div(id: 'container').images

# Finding images based on their class
browser.images(class: 'thumbnail')

Finding images on the page can be done in several ways. The code above contains several ways to find multiple images on a page.

Using regular expressions to match a CSS class 13/08/2012
# The following will match for a part of the CSS class(es) of a DIV element and 
# returns the element
browser.div(:class => /active/)

# The following checks if a DIV with a class of active exists
browser.div(:class => /active/).exists?

Matching a partial CSS class or one of several CSS classes can be done using the regular expression operator as shown above.

Finding an element inside of another element 26/07/2012
# Finding the containing element, for example a div
containing_element = browser.div(:id => 'footer')

# Finding a link inside of the containing element, i.e. footer 
link = containing_element.link(:class => 'footer_link')

It is in many cases useful to restrict finding of an element to another element containing it. For example, navigation links in the top navigation or footer link in the footer.

Retrieving all links on a page 26/07/2012
# all links
browser.links

# all links with the CSS class of navigation
browser.links(:class => 'navigation')

Retrieving multiple elements is as simple as using the plural form of the element name. Similar qualifiers as when searching for a single element can be used.

Finding a link with title 26/07/2012
browser.link(:title => "<link title>")

A link can be found with multiple methods. Sometimes using the title attribute is a good way to find it.

Finding a link with id 26/07/2012
browser.link(:id => 'link_id')

A link can be found with several methods. This tip shows how to find a link by specifying an ID.