Test Your Website’s Features In Firefox, Safari And Chrome Using Rspec and Capybara With Selenium.

First setup you mac as mentioned in Check Your Web-App’s Functionality Using Rspec, Cucumber And Capybara With Selenium. As of writing this post you can use firefox version 19 and chrome version 26 with selenium-webdriver (2.31.0). I hope you installed Homebrew. It really simplifies things. Selenium include FirefoxDriver and you do not have have to add any code for this. All you need is just install Firefox.

For Chrome, you have to install ChromeDriver.

brew install chromedriver

Now add the following code in spec_helper.rb to run tests on Chrome

Capybara.register_driver :selenium do |app|
  Capybara::Selenium::Driver.new(app, :browser => :chrome)
end

Installing SafariDriver is not so simple as ChromeDriver. We have to build the SafariDriver ourself. We have to install Google Go.

brew install go

Now you have to sign up for Apple’s (free) Safari Developer Program and generate a signed certificate for the extension from here https://developer.apple.com/certificates/index.action. Download the certificate and click it, then it will be added to keychain.

Now download the Selenium source Binaries.

cd ~/Downloads/
git clone https://code.google.com/p/selenium/

It will download all the selenium code which is about 1.2 GB. After that just goto the folder and compile with go.

cd selenium/
./go safari

It will create safari extention which we will use. It is better to copy the SafariDriver.safariextension folder to you Document folder. You can find SafariDriver.safariextension folder in ~/Downloads/build/javascript/safari-driver/

Now we need to enable the Develop menu (Preferences > Advanced > Show Develop menu in menu bar).

Open the Extension Builder (Develop > Show Extension Builder)

Click the add extension

Locate the SafariDriver.safariextension and select.

Now add the following code in spec_helper.rb to run test on Safari

Capybara.register_driver :selenium do |app|
  Capybara::Selenium::Driver.new(app, :browser => :safari)
end

About Zakir Hyder

This entry was written by .

27. March 2013 by Zakir Hyder
Categories: Black-box Testing, Capybara, Ruby, Selenium | Tags: , , , , , , , , , , , | Comments

Comments

  1. […] Test Your Website’s Features In Firefox, Safari And Chrome Using Rspec and Capybara With Selenium. March 27, 2013 4:20 PM […]