Difference between revisions of "Installing ruby with cucumber on a windows machine"

From Test Automation Wiki
Jump to: navigation, search
m
 
(34 intermediate revisions by 6 users not shown)
Line 2: Line 2:
 
<categorytree mode=all depth=1>Web_Test_Automation_Tutorial</categorytree>
 
<categorytree mode=all depth=1>Web_Test_Automation_Tutorial</categorytree>
 
</div>
 
</div>
 
  
  
 
<h2>Installing Ruby</h2>
 
<h2>Installing Ruby</h2>
 
[[File:winstall-ruby.png|right|225px]]
 
[[File:winstall-ruby.png|right|225px]]
# Download and the latest version of Ruby for windows '''32 bit''' on http://rubyinstaller.org/downloads/.
+
# Download the latest Ruby 2.6.x with devkit on http://rubyinstaller.org/downloads/.
#* Last confirmed functional Ruby: [http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.3.0.exe rubyinstaller-2.3.0.exe]
 
 
# Accept the terms
 
# Accept the terms
# Install to C:\Ruby
+
# Install Ruby in the default directory
 +
#* For example Ruby version 2.6 (64 bit) will be installed in C:\Ruby26-x64
 
# Check all 3 checkboxes
 
# Check all 3 checkboxes
<blockquote>
+
# And complete the installation
* We're installing Ruby 32 bit because 64 bit can cause issues.
+
 
* You can install to a different folder, but in the rest of this tutorial we will refer to this folder.
+
 
</blockquote>
+
<h2>Installing the plugins</h2>
 +
<p>Now the installation of Ruby is complete, we can start installing the necessary plugins. These are so called “Gems” in Ruby. (A ruby is a gem, so the creators decided to call their plugins gems)</p>
 +
 
 +
Copy the code written below and paste it in the CMD (right click, paste). While it's installing do not copy something else.
 +
<source>
 +
gem update --system
 +
gem install lapis_lazuli
 +
</source>
 +
 
 +
 
 +
<h2>Installing drivers</h2>
 +
For executing the test framework you need to have the following browsers installed: ''Firefox'' and ''Chrome''
 +
To let the framework communicate with the  browsers you need to download 2 drivers and place them in the ruby directory ''.../ruby/bin''
 +
 
 +
# Download the latest version of [https://sites.google.com/a/chromium.org/chromedriver/downloads chromedriver]
 +
# Download the latest version of [https://github.com/mozilla/geckodriver/releases geckodriver]
 +
# Unzip the downloaded files to <code>C:\Ruby\bin\</code> (Or where else you've installed Ruby)
 +
 
 +
<h2>Installing ANSICON</h2>
 +
 
 +
<p>When ANSICON is installed the test results in CMD will be colored. This will greatly improve the readability when working with Cucumber</p>
 +
 
 +
# Download the latest version of [https://github.com/adoxa/ansicon/releases ANSICON]
 +
# Unzip the file to <code>C:\ANSICON\</code>
 +
# Open CMD and navigate to the directory
 +
#* Navigate to ''x64'' (if you have a 64 bit machine) otherwise navigate to ''x86''
 +
#* To go to the directory write something like <code>cd C:\ANSICON\x64</code>
 +
# Type <code>ansicon.exe -i</code> and ansicon will be installed.
 +
#* Ansicon does not give a notification about the installation completed.
 +
 
 +
More information can be found here [http://qastuffs.blogspot.nl/2011/02/how-to-install-ansicon-for-cucumber-to.html source]
 +
 +
 
 +
<p>'''That's it! You're now ready to start setting up your cucumber project. You can read more about this in [[Creating your first ta project]]'''</p>
  
<h2>Installing DevKit</h2>
 
# Download and open the latest Devkit for Windows 32 bit on http://rubyinstaller.org/downloads/
 
#* Last confirmed functional DevKit: [http://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe]
 
# Extract to C:\Ruby\devkit\
 
#* [[File:winstall-devkit.png|225px]]
 
# Open command prompt
 
## Go to Run (Windows Key + R)
 
## Write 'cmd'
 
## Press enter
 
#* [[File:winstall-runcmd.png|225px]]
 
# Go to C:\Ruby\devkit
 
# Write <code>ruby dk.rb init</code>
 
# Write <code>ruby dk.rb install</code>
 
#* [[File:winstall-devkit-console.png|225px]]
 
#Configure config.yml if needed.
 
#* When you get the message "Invalid configuration or no Rubies listed. Please fix 'config.yml'". Please update your config.yml to point to the ruby folder. More info can be found [http://stackoverflow.com/questions/21184452/invalid-configuration-or-no-rubies-listed here].
 
  
 +
<h2>Extra information</h2>
  
 +
=== Information about the Ruby installation ===
  
 +
<p>This section is for you to have a better understanding of what is happening during the installation. And what the commands we're using in CMD actually mean.</p>
  
<h2>Installing the necessary plugins</h2>
+
<p>When we installed ruby, we checked a checkbox saying "Add ruby executables to your PATH". What we did here, was making ruby commands globally accessible in the CMD.</p>
<p>Now the installation of Ruby is complete, we can start installing the necessary plugins. These are so called “Gems”
 
    in Ruby. (A ruby is a gem, so the creators decided to call their plugins gems)</p>
 
  
Copy the code written below and paste it in the CMD (right click, paste)
+
<p>Now because these commands are global, we can go to devkit folder and write "ruby dk.rb install". Where we are actually saying: "Hey Ruby! I want you to look at this file dk.rb I have here and install it".</p>
<source>
+
 
gem update --system
+
<p>Same thing happens with "gem install lapis_lazuli": "Hey Ruby, I want you to do something with a gem, which is installing and the name is lapis_lazuli". After which Ruby is going to look online in their software system looking for a gem called lapis_lazuli.</p>
gem uninstall ffi
+
 
gem install ffi --platform ruby
+
 
gem install rspec --no-ri --no-rdoc
+
=== Information about gems ===
gem install win32console --no-ri --no-rdoc
 
gem install selenium-webdriver --no-ri --no-rdoc
 
gem install watir-webdriver --no-ri --no-rdoc
 
gem install lapis_lazuli --no-ri --no-rdoc
 
gem install cucumber --no-ri --no-rdoc
 
ruby -v
 
</source>
 
<blockquote>
 
'''While you're installing, do not copy any other text onto your clipboard or let your computer go to sleep. If you do so, CMD will stop installing after the last line of text.'''
 
</blockquote>
 
  
 +
Later in this tutorial we will install all required gems for Lapis Lazuli. A quick explanation about the gems we use:
  
 
{| class="wikitable collapsible collapsed"
 
{| class="wikitable collapsible collapsed"
! colspan="2"| More information about the installations above
+
! colspan="2"| More information about gems that were installed
 
|-
 
|-
 
| <code>gem update --system</code>
 
| <code>gem update --system</code>
 
| Will update all default gems installed with Ruby (can be outdated, even though you've just installed Ruby)
 
| Will update all default gems installed with Ruby (can be outdated, even though you've just installed Ruby)
 
|-
 
|-
| <source>gem install ffi --platform ruby
+
| <code>gem install selenium-webdriver --no-document</code>
gem uninstall ffi</source>
 
| This gem is problematic with Windows, so it needs to be re-installed with the <code>--platform ruby</code> argurment.
 
|-
 
| <code>gem install rspec --no-ri --no-rdoc</code>
 
| Commonly used gem
 
|-
 
| <code>gem install win32console --no-ri --no-rdoc</code>
 
| Will give coloured output.
 
|-
 
| <code>gem install selenium-webdriver --no-ri --no-rdoc</code>
 
 
| Gem that allows communication with browsers
 
| Gem that allows communication with browsers
 
|-
 
|-
| <code>gem install watir-webdriver --no-ri --no-rdoc</code>
+
| <code>gem install watir-webdriver --no-document</code>
 
| Layer on top of Selenium that simplifies browser interaction
 
| Layer on top of Selenium that simplifies browser interaction
 
|-
 
|-
| <code>gem install lapis_lazuli --no-ri --no-rdoc</code>
+
| <code>gem install lapis_lazuli --no-document</code>
 
| Test automation gem that will enforce best practices, forcing the TA engineer to produce better code.
 
| Test automation gem that will enforce best practices, forcing the TA engineer to produce better code.
 
|-
 
|-
| <code>gem install cucumber --no-ri --no-rdoc</code>
+
| <code>gem install cucumber --no-document</code>
 
| The software that will run the scripts from console.
 
| The software that will run the scripts from console.
 
|}
 
|}
  
<p>That's it! You're now ready to start setting up your cucumber project. You can read more about this in the next
+
=== Information about drivers for different browsers ===
    article.</p>
 
  
<h2>Extra installations</h2>
+
In our example we downloaded the drivers for Chrome and Firefox. However, there are many more browsers around like Safari, Internet Explorer, Opera, etc...
<p> if you'd like you can now also install [[Install_ANSICON_for_coloured_output|Ansicon]] so that test results will be colored in the commandline output </p>
+
By not installing the driver you would get a error message once you try to execute the project. Trying to run in Chrome without its driver results in the following error:
 
+
<source>
<h2>Extra information</h2>
+
Unable to find chromedriver. Please download the server from http://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH. More info at https://github.
<p>This section is for you to have a better understanding of what is happening during the installation. And what the
+
com/SeleniumHQ/selenium/wiki/ChromeDriver.
    commands we're using in console actually mean.</p>
+
(Selenium::WebDriver::Error::WebDriverError)
 
+
</source>
<p>When we installed ruby, we checked a checkbox saying "Add ruby executables to your PATH". What we did here, was
 
    making ruby commands globally accessible in the console.</p>
 
 
 
<p>Now because these commands are global, we can go to devkit folder and write "ruby dk.rb install". Where we are
 
    actually saying: "Hey Ruby! I want you to look at this file dk.rb I have here and install it".</p>
 
  
<p>Same thing happens with "gem install lapis_lazuli": "Hey Ruby, I want you to do something with a gem, which is
+
To make sure you can use this project in your preferred browser look for example on the internet for ''"<browser name> driver selenium"''
    installing and the name is lazpis_lazuli". After which Ruby is going to look online in their software system
 
    looking for a gem called lapis_lazuli.</p>
 
  
  
 
[[Category:Installing ruby with cucumber]]
 
[[Category:Installing ruby with cucumber]]

Latest revision as of 14:32, 21 September 2020


Installing Ruby

Winstall-ruby.png
  1. Download the latest Ruby 2.6.x with devkit on http://rubyinstaller.org/downloads/.
  2. Accept the terms
  3. Install Ruby in the default directory
    • For example Ruby version 2.6 (64 bit) will be installed in C:\Ruby26-x64
  4. Check all 3 checkboxes
  5. And complete the installation


Installing the plugins

Now the installation of Ruby is complete, we can start installing the necessary plugins. These are so called “Gems” in Ruby. (A ruby is a gem, so the creators decided to call their plugins gems)

Copy the code written below and paste it in the CMD (right click, paste). While it's installing do not copy something else.

gem update --system
gem install lapis_lazuli


Installing drivers

For executing the test framework you need to have the following browsers installed: Firefox and Chrome To let the framework communicate with the browsers you need to download 2 drivers and place them in the ruby directory .../ruby/bin

  1. Download the latest version of chromedriver
  2. Download the latest version of geckodriver
  3. Unzip the downloaded files to C:\Ruby\bin\ (Or where else you've installed Ruby)

Installing ANSICON

When ANSICON is installed the test results in CMD will be colored. This will greatly improve the readability when working with Cucumber

  1. Download the latest version of ANSICON
  2. Unzip the file to C:\ANSICON\
  3. Open CMD and navigate to the directory
    • Navigate to x64 (if you have a 64 bit machine) otherwise navigate to x86
    • To go to the directory write something like cd C:\ANSICON\x64
  4. Type ansicon.exe -i and ansicon will be installed.
    • Ansicon does not give a notification about the installation completed.

More information can be found here source


That's it! You're now ready to start setting up your cucumber project. You can read more about this in Creating your first ta project


Extra information

Information about the Ruby installation

This section is for you to have a better understanding of what is happening during the installation. And what the commands we're using in CMD actually mean.

When we installed ruby, we checked a checkbox saying "Add ruby executables to your PATH". What we did here, was making ruby commands globally accessible in the CMD.

Now because these commands are global, we can go to devkit folder and write "ruby dk.rb install". Where we are actually saying: "Hey Ruby! I want you to look at this file dk.rb I have here and install it".

Same thing happens with "gem install lapis_lazuli": "Hey Ruby, I want you to do something with a gem, which is installing and the name is lapis_lazuli". After which Ruby is going to look online in their software system looking for a gem called lapis_lazuli.


Information about gems

Later in this tutorial we will install all required gems for Lapis Lazuli. A quick explanation about the gems we use:

Information about drivers for different browsers

In our example we downloaded the drivers for Chrome and Firefox. However, there are many more browsers around like Safari, Internet Explorer, Opera, etc... By not installing the driver you would get a error message once you try to execute the project. Trying to run in Chrome without its driver results in the following error:

Unable to find chromedriver. Please download the server from http://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH. More info at https://github.
com/SeleniumHQ/selenium/wiki/ChromeDriver.
(Selenium::WebDriver::Error::WebDriverError)

To make sure you can use this project in your preferred browser look for example on the internet for "<browser name> driver selenium"