---
title: "#116 Selenium"
author: "CaiDeHen"
date: "2008-12-12T14:11:15Z"
tags: []
slug: "116-selenium"
draft: false
lastmod: "2008-12-12T14:11:15Z"
id: 291986
url: "https://caidehen.iteye.com/blog/291986"
---

Selenium is a great way to test your app automatically through a browser. See how it works in this episode.

```java
script/plugin install git://github.com/ryanb/selenium-on-rails.git
script/generate selenium destroy_product.rsel

# test/selenium/destroy_product.rsel
setup :fixtures => :all
product = Product.first
open '/'
click "css=#product_#{product.id} a:contains('Destroy')"
assert_confirmation('*')
wait_for_element_present "css=#flash_notice"
assert_element_not_present "css=#product_#{product.id}"
refresh
assert_element_not_present "css=#product_#{product.id}"

# config/selenium.yml
environments:
  - test

browsers:
  firefox: '/Applications/Firefox.app/Contents/MacOS/firefox-bin'

```