The good folks at Ministry of Testing are running a UI Automation week from Monday 22nd February.

As part of the event, there are a set of UI Automation challenges. Designed to test existing skills and develop new ones.

Here is my solution using Ruby and Selenium WebDriver to assert that the ‘Create’ button appears on the Restful Booker Platform for the UI check challenge.

You can check out the event at UI Automation Week

require 'rubygems'
require "selenium-webdriver"
require "test/unit"

class AwTest < Test::Unit::TestCase

	def test_assert_button

		#Chrome browser instantiation
		driver = Selenium::WebDriver.for :chrome

		# maximize the browser window.
		driver.manage.window.maximize

		#Loading the Restful Booker URL
		driver.navigate.to "https://automationintesting.online/#/admin"

		# create a wait with a timeout of 15
		wait = Selenium::WebDriver::Wait.new(timeout: 15)

		# dismiss dropdown
		button = wait.until {
		element = driver.find_element(:xpath, "//button[text()='Let me hack!']")
		element if element.displayed?
		}
		button.click()

		#Populate username
		input = wait.until {
		element = driver.find_element(:id, "username")
		element if element.displayed?
		}
		input.send_keys("admin")

		#Populate password
		input = wait.until {
		element = driver.find_element(:id, "password")
		element if element.displayed?
		}
		input.send_keys("password")

		# click login button
		button = wait.until {
		element = driver.find_element(:id, "doLogin")
		element if element.displayed?
		}
		button.click()

		# assert create button
		button = wait.until {
		element = driver.find_element(:id, "createRoom")
		element if element.displayed?
		}
		assert(button.text.include?("Create"))

		driver.quit

	end

end


Let's See It in Action




Russell Morley

Test Lead | Software Developer In Test | Automation Enthusiast