Selenium sample application
This is the sample application I wrote to show how Selenium and Rspec can be used together to test an arbitrary web application. And you can run the tests on remote computers and virtual machines! I wrote two blog posts explaining this stuff, here's the first and here's the second.
This application will help you understand Selenium. Selenium allows you to control web browsers with source code. This application uses selenium to drive a web browser to visit a simple Rack web server, and test it.
- Install ruby on your computer. I recommend rbenv.
- Clone this repo
git clone email@example.com:LinuxFan2718/selenium_grid_sample.git cd selenium_grid_sample
- Install the bundler gem
gem install bundler
- Install the gems for this application
- Start the thin web server
bundle exec thin start -R server.ru
- Change to another terminal and run the selenium test suite
bundle exec rspec
You should see a firefox instance pop open, visit http://localhost:3000, and close itself. On the terminal, you should see one test run and pass.
By reading the source code of this application you will see how to use Selenium.
- The selenium-webdriver docs are essential.
- The official page about Selenium WebDriver.
- The rspec docs
- Archive of Selenium tips
- Race conditions explained
- Using a Firefox extension to work around Selenium WebDriver's limitations
- Although I don't use Page Objects in this sample application, I always use them in real test suites. A quick primer on Page Objects
- An introduction to Browserstack