Skip to main content

Getting Started with Ruby + Capybara + Cucumber in Windows ft. Duck Duck Go

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/

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.

Setting Up Your Test Environment

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
Right now, you probably have several questions in mind.

"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

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.



My future reference/s:

Popular posts from this blog

Reframing how I identify bug root causes

It's been more than a year now since I've set up our bug tracking in JIRA. In there, I've set up an Issue Root Cause custom field where it had the following options: Incorrect coding Unclear / Missing / Incorrect Requirements Unclear / Missing / Incorrect Design Insufficient / Duplicated / Incorrect Testing Deployment Issue Environment Third-party issue My thoughts when I listed these as options is so that it would be easy to identify which team is responsible for the cause why we had that bug. They're pretty straightforward -  Incorrect coding  is of course when the developers didn't follow the expectations,  Unclear / Missing / Incorrect Requirements is because there's a gap in the requirement, and so on. And also, it's because that was the way it's done in my previous company so that's also my initial knowledge source. Recently, I've been reading a few articles regarding Shift Left, reducing silos, and generally how quality is a team activit...

QA Tools: Custom Test Case Generator in Google Sheet using Google App Script

When testers have to document test cases, it's usually done in the traditional format of putting all your test cases and steps in one sheet. Once it accumulates, for me it can be overwhelming to look at. It looks something like this: As a solution, I decided to make a tool that will help me focus on only drafting my test scenarios and look at my test cases one at a time. I'd like to share this here with everyone else who's like me. Hopefully, it can make your testing journey even a little better. Test Case Generator Tool This tool is for QA or non-QAs who need to write test cases. What it can do: Write your test scenarios in one tab Focus on writing steps for each test case one sheet at a time Generate an import file Generate a test execution document Sample test execution document: Scroll to the bottom to see how it works. Sheet Purpose Test Scenarios This is where you set the details for this test set/the project/story/epic where you're creating the test cases u...

A Bug's Life! Defect Management Process in Software Testing

First things first, what does a "bug" mean in the software development process? A bug is what we call a behavior that is different from what's expected based on the provided requirements. A tester's main purpose is to find and report bugs in the system as early as possible. In some companies, it's sometimes called a "defect". They actually mean slightly different if we go by the book. In this post, I'll be covering the lifecycle of a software bug which are issues that are found during the development phase. You're testing the system and you found a bug. What is the first thing you do? a) You immediately write a bug report b) You try to reproduce it c) You complain "How could this very obvious bug reach QA? Dev should've spotted this earlier ugh." The formal answer is B (I'll just let you figure out what's the informal answer), It's common for a QA to be gaslighted. "I cannot reproduce this bug.", "It doesn...