I used Selenium about 6 years ago when I was working on my MSc, and was testing mobile web applications for W3C best practice implementation. Recently, I had cause to install Selenium again to do some web application testing at work that I wanted to automate – but this time, instead of using the Java binding, I used Ruby. I captured the notes below on how to get all this set up.
Firstly, you can get the Selenium webdriver gem by running:
gem install selenium-webdriver
The documentation is available at: http://seleniumhq.github.io/selenium/docs/api/rb/.
Anyways, I decided to use the Firefox driver, as I like working with the Firefox Dev tools, and the setup is a bit quicker than using Chrome. Just make sure Firefox is installed on your dev machine and you will be good to go with this.
To get up and running, I wrote a ruby script to connect to the web application, log in and click some screen elements to navigate around the UI.
require "selenium-webdriver" #set up webdriver driver = Selenium::WebDriver.for :firefox driver.manage.timeouts.implicit_wait=5 driver.navigate.to "http://localhost/jams/login" #get creds to login username = driver.find_element(:id, "mat-input-0").send_keys "username" password = driver.find_element(:id, "mat-input-1").send_keys "password" #click on login form = driver.find_element(:tag_name, "button").click #just print the title to make sure it works. puts driver.title # find the Definitions folder and open it definitions = driver.find_elements(:class, "nav-item-label") definitions.click #expand the menu to see all the subfolders expand = driver.find_element(:class, "toggle-children").click #close the webdriver #driver.quit