Example of using Ruby with Cucumber and Selenium WebDriver for automated UI tests.
The feature files, step definitions and page objects were written for https://github.com/andreasneuber/automatic-test-sample-site. Readme in that repo has further details how to set it up.
-
On Windows install Ruby as outlined here: https://rubyinstaller.org/
-
Install also bundler: https://www.geeksforgeeks.org/how-to-install-ruby-bundler-on-windows/
-
Make sure ChromeDriver is installed on your system (see also FAQ below)
-
Clone project
git clone https://github.com/andreasneuber/ruby-cucumber-selenium-framework.git
- Install required dependencies
bundle install
# all at once..
cucumber
# or
cucumber features/AdminPrivileges.feature
# or
cucumber features/ConvertCelsius.feature
# or
cucumber features/Creditcard.feature
# or
cucumber features/Login.feature
# or
cucumber features/ProvideYourDetails.feature
# or
cucumber features/ConcurrentWindows.feature
Bash:
export now=$(date +"%Y-%m-%d_%H-%M-%S") && cucumber -f pretty -f html -o reports/$now.report.html
PowerShell:
$now = "reports/" + ((Get-Date).ToString('yyyy-MM-dd_hh-mm-ss') | Out-String).Trim() + ".report.html"; cucumber -f pretty -f html -o $now
Report will appear in directory reports
where it can be opened in a browser.
bundle update
There is different ways, one possibility:
- Go to https://googlechromelabs.github.io/chrome-for-testing/ > Channel 'Stable'
- Download the win32 or win64 version
- Save
chromedriver.exe
somewhere in your file system - Edit environment variables > System Variables > Path and path to your Chromedriver location
- If necessary restart machine
- To check if all is good with cmd
chromedriver -version
which should give you the correct version number - Put file
update_chromedriver.sh
into the folder wherechromedriver.exe
is located - To update Chromedriver:
bash update_chromedriver.sh
- This should download the latest Chromedriver
Please have a look at features\support\env.rb
and there at the Before do
block in particular.
Please have a look here: https://hub.docker.com/u/selenium > selenium/standalone-chrome