Cucumber Installation
Below are the steps i used on a VM. There are many similar steps found but the basics seem consistent. issues may be that conflicts appear or missing gems.
========================================
These steps assumes you have knowledge of GitHub, Jenkins, VM ,…
VM setup with Cucumber and running on Jenkins
name/IP
=======================================
STEP 0: INSTALL GIT and CLONE REPO on VM
see Git instructions here:
I followed instructions from here:
other installation guide:
- https://sqaengine.wordpress.com/2014/05/14/installing-cucumber-and-capybara-in-windows-8-64-bit-os/
- http://help.rubygems.org/discussions/questions/82-how-to-install-ruby-devkit-and-cucumber-on-windows-without-internet-connection
- https://sakib.wordpress.com/2015/10/31/simple-cucumber-installation-in-windows-7/
STEP 1: INSTALL RUBY (v. 2.2.X)
from http://rubyinstaller.org/downloads
- Install on C drive. example C:\Ruby22-x64 and all the options checked
- installed version: Ruby 2.2.4 (x64) on VM: 10.50.87.62
- or install latest stable version
We may need a VM or a separate installation of Ruby to test the latest version 2.X. I believe more than one version of Ruby can co-exist.
Yes it’s possible to have two versions of Ruby installed on your machine at the same time. You can then select which version to run by launching the corresponding Command Prompt with Ruby.
I ran in to a cucumber-core error when attempting to execute tests using Ruby 2.3.3. Due to this error, and the fact that Ruby version 2.2.X is the recommended version according to http://rubyinstaller.org/downloads do not upgrade your version of Ruby beyond 2.2.X for the time being.
SCREENSHOTS
STEP 2: INSTALL RUBY DEVELOPMENT KIT
from http://rubyinstaller.org/downloads/
see: https://corlewsolutions.com/articles/article-22-install-ruby-devkit-on-windows-7
- installed version: DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe on VM: xx.xx.xx.xx
- install on C:\DevKit per instructions (very important!)
- When asked where to extract, enter a path with no spaces. C:\DevKit is HIGHLY recommended (or another path that does not contain a folder name with spaces).
- DO NOT rename the directory after the files have been extracted; the path has been hard coded into the Ruby installation. The rest of these directions assume the files were extracted to C:\DevKit.
Head over to the Ruby Installer downloads page and grab the DevKit .exe file that matches the version of Ruby being used on the machine.
If you need to find the version of Ruby, open a terminal and run:
ruby -v
If x64 appears in the output, 64bit Ruby has been installed. If x86 appears in the output, 32bit Ruby has been installed.
Open a terminal, and run:
cd c:\DevKit ruby dk.rb init ruby dk.rb install
! had an issue with invalid configuration when typing “ruby dk.rb install” found solution here:
— http://stackoverflow.com/questions/30113666/invalid-configuration-or-no-rubies-listed-please-fix-config-yml-and-rerun-ru
open config.yml in notepad and added:
--- C:\Ruby22-x64 ---
To Test the DevKit Installation was successful
To test the DevKit installation, we will try to install the JSON gem. Open a terminal and run:
gem install json --platform=ruby
The JSON gem should install correctly and you should see a message about Building native extensions. Next, let’s actually use the JSON run and run:
ruby -rubygems -e "require 'json'; puts JSON.load('[42]').inspect"
If everything worked correctly, the screen should show:
# [42]
if SSL issue:
C:\DevKit>gem install json --platform=ruby ERROR: Could not find a valid gem 'json' (>= 0),
Here is why:
Unable to download data from https://rubygems.org/ – SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)
see:
- http://guides.rubygems.org/ssl-certificate-update/ and Download rubygems-update-2.6.7.gem (or latest)
- http://help.rubygems.org/discussions/problems/19586-gem-install-gets-certificate-error
- https://gist.github.com/luislavena/f064211759ee0f806c88
Download rubygems-update-2.6.7.gem
Please download the file in a directory that you can later point to (eg. the root of your harddrive, C:\
)
Now, using your Command Prompt:
C:\>gem install --local C:\rubygems-update-2.6.7.gem
C:\>update_rubygems --no-ri --no-rdoc
After this, gem --version
should report the new update version.
SCREENSHOTS
STEP 3: INSTALL RUBYGEMS PACKAGE
if you want to do it manually, otherwise follow Step 4
Follow STEP 4 below to install the following from the GEMFILE
Install Ruby Gems (RubyGems is a package management framework for Ruby.)
in console, go to: C:\Ruby22-x64 or in C:\DevKit>
You will need to run the command prompt as Administrator
type:
gem install package
SSL ERRORS
get updates if SSL error/issues
type:
gem install rubygems-update update_rubygems
or follow manual instructions here: https://rubygems.org/pages/download
also check out: http://stackoverflow.com/questions/19150017/ssl-error-when-installing-rubygems-unable-to-pull-data-from-https-rubygems-o/27298259#27298259
or http://help.rubygems.org/discussions/problems/19586-gem-install-gets-certificate-error
after you should have: 2.6.8 or latest version!
example:
C:\Devkit>gem -v 2.6.8
OTHER POSSIBLE ISSUES:
http://stackoverflow.com/questions/19417715/adding-devkit-to-environmental-path
You should be able to add Devkit to your Environment Variables doing the following from within Control Panel » System » Advanced » Environment Variables
:
- Add a new “System Variable”– Variable Name:
DEVKIT_HOME
— Variable Value:C:\Devkit
- Edit System “Path” variable’s value by appending the following:–
;%DEVKIT_HOME%\bin;%DEVKIT_HOME%\mingw\bin
- Of course the final step: “Reboot the machine”.
You could of course skip adding DEVKIT_HOME
variable and directly update the Path
variable with C:\Devkit\bin;C:\Devkit\mingw\bin
.
TO INSTALL GEMS
You should be able to install the required Ruby gems. Now, you could install these manually, like this:
gem install cucumber |
gem install rspec |
gem install mechanize |
gem install capybara |
gem install selenium-webdriver |
gem install capybara-mechanize |
However, there’s a more convenient way. First, create a file in the project’s root directory called Gemfile and put the following content into it:
source “https://rubygems.org” |
gem “cucumber” |
gem “rspec” |
gem “mechanize” |
gem “capybara” |
gem “selenium-webdriver” |
gem “capybara-mechanize” |
…and any additional gems you want.
Then install the Bundler gem:
gem install bundler
Then use Bundler to install the required gems:
bundle install
This makes it easier to get your project set up somewhere else because you can put the Gemfile under version control, making it easier to duplicate this setup elsewhere.
see SPECIFIC STEPS BELOW FOR GIT Integration…
STEP 4: Install Gems from the GEMFILE (for Ruby version 2.2.X): (latest version 2.4.x works!)
Bundler provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed (and listed in the GEMFILE).
Create the GEMFILE
More info on Bundler:
STEP A:
- do a “git pull upstream master” to update your local repo with the latest files
- Open a terminal and navigate to the dir where the gemfile is. example: C:\Users\smyusername\Desktop\GIT\Cucumber-Tests
STEP B: to install the gem “bundler” which is needed for next step (manually) – otherwise do “STEP C” below, as this “Bundler” is in the GEMFILE already! (not sure this will work though)
type:
gem install bundler
STEP C: Instruction to install all the gems per the gemfile via the “bundler”.
after installation type:
bundle install
STEP D: to confirm all the correct gems/versions are installed
to confirm the list of gems installed, type:
gem list
OR install gems individually if you want to… but you really don’t need to if you’ve installed all the required Gems with the GEMFILE…
1: Install CUCUMBER (+ related cucumber gems like Gherkin, etc…)
in C:\DevKit>
gem install cucumber
for cucumber commands:
cucumber -help
2: Install CAPYBARA (+ related gems)
this is a Cucumber library for step definitions
in C:\DevKit>
gem install capybara
NOTE: to download and install the Capybara web automation library.
http://www.rubydoc.info/github/jnicklas/capybara/master/Capybara
https://github.com/jnicklas/capybara
3: Install SELENIUM WEBDRIVER
in C:\DevKit>
gem install selenium-webdriver
- if webdriver errors: you may have to update the ruby gem:
To update gem: navigate to: C:\DevKit
gem update selenium-webdriver
4: Install RSPEC (+ related gems)
this is a Cucumber library for step definitions
NOTE: It is an extensive library for assertions. (By the way there is a very nice tutorial at codeschool.com, its name is “Testing with RSpec”. I suggest you to check that course.)
in C:\DevKit> or C:\
gem install rspec
this gem is not part of the rspec gem package so you will need to install separately
gem install rspec-expectations
this gem is not part of the rspec gem package so you will need to install separately
gem install rspec-matcher
5: OTHER GEMS you will need;
see GEMFILE for complete list.
in C:\DevKit> or C:\
gem install <NAME-OF-GEM>
to check which ones are used/needed look at the env.rb files and the gemfile for more up to date list!
STEP 5: INSTALL ANSICON (Optional)
on Windows 10, Ansicon is preventing Chromedriver to launch the browser. so i have uninstalled it. Unless there is a step in installation required. ?
C:/ansi160/x64>ansicon.exe -u
To show colorized text in cmd prompt when running cucumber tests locally.
In command prompt
- A “Pass” Cucumber test case is shown in Green
- A “Fail” Cucumber test case is shown in Red
To show colorized text in cmd prompt you have to install Ansicon tool.
if on VM this is not required but highly recommended on local machines when debugging.
instructions here:
- http://maxivak.com/installing-ansicon-for-colored-output-for-ruby-on-rails-tests-on-windows/
- http://qastuffs.blogspot.com/2011/02/how-to-install-ansicon-for-cucumber-to.html
Installation For AnsiCon:
Step 1) Download Ansicon here or from https://github.com/adoxa/ansicon/downloads. or https://github.com/adoxa/ansicon
Step 2) Select a folder as per your windows OS versions
Step 3) Execute file ansicon
with Ansicon:
STEP 6: WRITING AUTOMATION WITH RUBY & CAPYBARA & CUCUMBER
Sublime (trial) or Atom:
I chose to install https://www.sublimetext.com/2
to make it easier to write test files and folders
– https://github.com/maltize/sublime-text-2-ruby-tests
OR
– https://github.com/npverni/cucumber-sublime2-bundle
download the bundle.
- From within Sublime, click “Preferences” from the top menu
- Click “Browse Packages” to open explorer to the packages directory
- Create a new folder called “Cucumber”
- Copy the 2 *.tmLanguage files from this project into your new directory
- (Cucumber Plain Text Feature.tmLanguage and Cucumber Steps.tmLanguage)
PACKAGES FOR SUBLIME TEXT
————————-
https://packagecontrol.io/search/cucumber
https://packagecontrol.io/search/cucumber%20sublime%20text
I INSTALLED THE FOLLOWING;
https://packagecontrol.io/packages/Cucumber
https://packagecontrol.io/packages/RubyTest
https://packagecontrol.io/packages/Gherkin%20(Cucumber)%20Formatter
Atom (free):
Download link: https://atom.io/
STEP 7: TEST DRIVE YOUR CUCUMBER INSTALLATION
select a local folder as your test, this should be outside of your local git folder
open “command prompt with Ruby”
type the following; this will create the default folder structure.NOTE that our QA Automation in git uses a different structure.
cucumber --init
TROUBLESHOOTING
issue with gecko driver:
Unable to find Mozilla geckodriver. Please download the server from:
https://github.com/mozilla/geckodriver/releases and place it somewhere on your PATH. More info at:
https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver. (Selenium::WebDriver::Error::WebDriverError)
Download geckodriver and install in your env. variable PATH
see:
- http://toolsqa.com/selenium-webdriver/how-to-use-geckodriver/
- http://toolsqa.com/selenium-webdriver/how-to-use-geckodriver/
RUBY:
update environment variable PATH: for webdriver.
example: C:\Ruby22-x64\bin
Firefox GeckoDriver issue
If Issues come up, here are steps I did to fix on the VM
from: https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
- in command prompt, for ruby
- gem install selenium-webdriver to make sure you have latest version
- download geckodriver from https://github.com/mozilla/geckodriver/releases
- Add directory where executable is (geckodriver.exe) to system path ( via System Properties and set system variables. Or on window’s Cortana type “environment variable” to select the System Properties)
-
- example on Windows: C:\Git\Cucumber-Tests\BROWSER-DRIVERS\geckodriver-v0.13.0-win64
- so Path will look like this:
- C:\Users\xxxxxx\Ruby22-x64\bin;…….;C:\Git\Cucumber-Tests\BROWSER-DRIVERS\geckodriver-v0.13.0-win64
- Note: Alternatively for Windows 10, you can add the geckodriver.exe to your Ruby folder (i.e. C:\Ruby23-x64\bin) and ensure to include this path in STEP3 (i.e. C:\Ruby23-x64\bin ).
4. restart your “command prompt with ruby” before running cucumber tests again manually
5. you may need to update your firefox, which is what i did on the vm, and now the tests run again!
Check if you have “http://rubygems.org/” as a source to find gems at:
$ gem sources
will return list of sources.
you should see:
*** CURRENT SOURCES *** https://rubygems.org/
add the following:
$ gem sources --add http://rubygems.org/
http://rubygems.org/ added to sources
ALSO IF ISSUES…
You are behind a firewall or virus software. You need to switch to use http://rubygems.org instead of https://rubygems.org.but HTTPS is recommended!
You can use the gem sources -r https://rubygems.org then -a http://rubygems.org
it will remove the https and add just the http if you are having this issue you will have to change it in your Gemfile of your test app as well or your server won’t run.
git clone https://git.YOURSITE.com/Directory/Cucumber-Tests.git
git commit -m "my comment" Path/features/title.feature