After 5 days of rest and finally getting my own laptop, the time to study Ruby finally came.
I've been trying to figure out the best approach to start learning it. I downloaded PDFs that I hoped to read after I got home from work and browsed related articles, but I can't focus. I just feel the itch to try setting it up first and do a simple exercise just so I can familiarize myself with it... and so this happened.
Please note that I am not a highly proficient Ruby person as of now. The intent of this post is just for me to document how I did the setup and followed the exercise I found online. If you are also just starting like me, I hope this helps :)
Btw, I used Notepad++ as my for scripting.
---
Installing Ruby
Reference/s:
Ruby in 20 minutes: https://www.ruby-lang.org/en/documentation/quickstart/
I've been trying to figure out the best approach to start learning it. I downloaded PDFs that I hoped to read after I got home from work and browsed related articles, but I can't focus. I just feel the itch to try setting it up first and do a simple exercise just so I can familiarize myself with it... and so this happened.
Please note that I am not a highly proficient Ruby person as of now. The intent of this post is just for me to document how I did the setup and followed the exercise I found online. If you are also just starting like me, I hope this helps :)
Btw, I used Notepad++ as my for scripting.
---
Installing Ruby
Reference/s:
Ruby in 20 minutes: https://www.ruby-lang.org/en/documentation/quickstart/
Installing Ruby: https://www.ruby-lang.org/en/documentation/installation/
Ruby Installers: https://rubyinstaller.org/downloads/
Of course the first thing to do is set up the environment. I just followed the instructions from the first 2 links.
Basically, just go to the 3rd link and if you are a first timer like me and you don't know what you need, just follow the instructions from the website.
Reference/s:
Introduction to Selenium with Ruby Capybara and Cucumber: https://rossoneill.ca/introduction-selenium-ruby-capybara-cucumber/
Once the installation is complete, create your workspace and open its directory in the command prompt then run these commands:
- gem install capybara
- gem install cucumber
- gem install selenium-webdriver
- cucumber --init
"What is a gem??". Since I'm more familiar to Java, based on my observation gems are basically external libraries or plugins. If you have limited programming background, basically it's a collection of codes created by someone else that you can reuse so you don't have to do reinvent the wheel.
Follow the rest of the instructions such as updating your env.ruby file, creating your feature file, and your step definitions.
"What is Capybara? Why do I need it?" As stated in the references, Capybara is a Ruby library (gem) that will help you give commands to your web browser. I believe it's created on top of Selenium-webdriver.
"What is Cucumber??" Cucumber lets you write your test using Gherkin Language which is close to the English language. An advantage of this is it's easy to understand by non-testers and non-technical person. Your test cases can also serve as a documentation of system behavior.
Follow the rest of the article and viola! You complete your first automated test case!
Troubleshooting
Sometimes, tutorials aren't perfect. Even if you follow everything to perfectly, IT. JUST. WON'T. WORK. I felt that.
I only had one issue and that is setting up the GeckoDriver (Selenium WebDriver for Firefox). The step wasn't mentioned in the article.
"PATH?? What do you mean PATH?" I honestly have no idea that PATH the error is talking about. I assumed it was the Window's Environment Variables so I added the directory of my GeckoDriver there, still didn't work. I tried to update my env.rb, still didn't work. I spent more than an hour tring to figure it out until I finally found the solution.
Solution: http://www.testautomation.info/Unable_to_find_Mozilla_geckodriver_Please_download_the_server_from_and_place_it_somewhere_on_your_PATH
Solution: http://www.testautomation.info/Unable_to_find_Mozilla_geckodriver_Please_download_the_server_from_and_place_it_somewhere_on_your_PATH
After I saved my GeckoDriver in Ruby's bin folder, it finally worked (yay)!
Here's the finished product:
After doing this simple exercise, I have the peace of mind now to read my PDFs.
I know I probably jumped right away with Capybara and Cucumber for Ruby test automation. After reading a few chapters to be familiar with the syntax, I'll do another exercise where I'll automate the same test by only using Ruby and Selenium-webdriver.
Selenium Test Automation With Ruby: http://seleniummaster.com/sitecontent/index.php/selenium-web-driver-menu/selenium-test-automation-with-ruby
Ruby Cucumber Capybara: https://www.swtestacademy.com/ruby-cucumber-capybara/

