November 6, 2021

The Cheezy Internet: Installing Ruby + Watir + Chromedriver + VS Code on Windows 10

This is second in a series of blog posts. Care to go back to the beginning?

For this exercise, we will be setting up a Windows 10 box for use as a development machine.

Macbooks are amazing machines. I love coding on them. Using the Mac Terminal in Homebrew. Dressing them up with decals, such as the glasses-and-tie decal my wife bought for my very first work laptop back at Fitbit-Boston.

Apple Logo Dressed in glasses and a tie
Love dressing up the Apple logo!

I definitely would not recommend using your work machine, if you have one, for anything but work and work-related activities. 

The problem is that when it comes to non-work related programming activities, it can leave for me, well, less glamourous and sparkly alternatives.  

My home computer always has been a Windows Desktop, a big ole workhorse to store the family photos and videos, ancient video games like the original StarCraft, old blog posts, articles, and essays. But they can be so hard to set up sometimes with the toolsets I need to put together an automation framework. 

Based on the information in Jeff "Cheezy" Morgan's LeanPub book, "Cucumbers and Cheese: A Tester's Workshop" (2017), we will start setting up our local machine. 


Open up PowerShell as Administrator

The windows version of the Mac Terminal, I like using is PowerShell as a command line interface (cli).  If you are on a Windows machine, to get to PowerShell: 
  • Click Start, type PowerShell, and then click Windows PowerShell
  • Right click on PowerShell and choose "Run as Administrator". You will need those special permissions in order to greenlight the installations we are doing.

Create a Directory for Source code

When tinkering on my home computer, I like storing my source code in my Home directory in a subfolder marked "src": 

  • Go to the Home directory by changing the directory: cd ~
  • Make a directory called "src":  mkdir src
  • Change into the src directory: cd src
  • Confirm that you are in the correct directory by printing the working directory: pwd

Install Ruby on Windows


To install Ruby on Windows, we will be using RubyInstaller

From RubyInstaller/ About: "The RubyInstaller project provides a self-contained Windows-based installer that includes a Ruby-language execution environment and a baseline set of required RubyGems and extensions, integrated with a MSYS2 installation.

"To install Ruby, in the Download section choose the version you would like, and click the .exe link (under the name of the version) to download the installer. Use Windows Explorer to navigate to where you saved the .exe file and double-click it to run the installer.

"The Ruby Installer is currently available only for Windows platforms".

Install Watir 

To write code that interacts with our web application under test, we will be using Watir: Web Application Testing In Ruby. Watir is, according to Watir.com, "An open source Ruby library for automating tests. Watir interacts with a browser the same way people do: clicking links, filling out forms and validating text".

Install the Ruby gems for ffi and watir by typing into PowerShell:
  • gem install ffi
  • gem install rake bundler watir

Download Chromedriver

To install Chromedriver on Windows, let's install Chocolatey, a package manager for Windows. Chromedriver will take the Watir code we write and control Chrome, clicking on buttons and filling out textboxes. 

Make sure when using PowerShell: Run as administrator

Set up an IDE

When coding, it helps to have an Integrated Development Environment, an all-in-one platform where you can write and execute your code. Personally, I like VS Code when coding in Ruby. https://code.visualstudio.com/

From VS Code / Why VS Code?: "Visual Studio Code combines the simplicity of a source code editor with powerful developer tooling, like IntelliSense code completion and debugging.

"First and foremost, it is an editor that gets out of your way. The delightfully frictionless edit-build-debug cycle means less time fiddling with your environment, and more time executing on your ideas".

Install various VS Code extensions such as: 
  • VS Code for Ruby
  • Cucumber (Gherkin) Full Support

Verify Setup: Create First Script

To check that everything is working, I created, per Jeff Morgan's  "Cucumbers and Cheese: A Tester's Workshop" a new file called "first_script", adjusting it so it goes to a sample Login page on Dave Haeffner's test site, The-Internet (https://the-internet.herokuapp.com/login):

Using VS Code, open up the /src folder, create a new file called: first_script. 

first_script.rb
 require 'watir'  
 browser = Watir::Browser.new :chrome  
   
 browser.goto 'https://the-internet.herokuapp.com/login'  

To run the script in the Terminal, type:
  • ruby first_script.rb

Chrome will open up a new browser, go to the website, then close the browser.

Congratulations! We wrote our first Watir script! 

What Does This Code All Mean? 


More about this script, according to Jeff Morgan: 

require 'watir'

"The first line of the script informs Ruby of the library (or gem) we need to be loaded in order to run the script. More specifically, it loads the watir gem."

browser = Watir::Browser.new :chrome

"The second line is where things get interesting. On this line we are creating a new Watir Browser object for Chrome and give it the name browser. This is a common pattern we will see throughout our scripts. When we create the new browser object it opens the actual browser application on our computer, and assigns it to the Watir Browser object, so that we can have control of that browser application".

browser = Watir::Browser.new :chrome

"You may have noticed that on line three of the script we are creating our browser object
by calling Watir::Browser.new. Just what exactly is the Watir::? That is what we call
a namespace. It is so we keep our classes organized and do not have name collisions.
For example, there might be other gems that want to have a class named Browser.
How can we tell them apart? Namespaces help us with this. When we make a call to
Watir::Browser.new what we are saying is “look inside the Watir namespace for a class
named Browser and make a new one for me”.

browser.goto 'https://the-internet.herokuapp.com/login'

"The final line of the script is where we inform the actual browser, through our Browser object, to surf to the Apple website. The way we do this is by sending a message to the browser object. That message is goto. As you might imagine, the remainder of the line is passed along with the message informing the browser which URL to go to."

The next blog entry, we will start examining our application under test, Dave Haeffner's The-Internet, and craft a few test cases. 


Happy Testing!

-T.J. Maher
Sr. QA Engineer, Software Engineer in Test
Meetup Organizer, Ministry of Testing - Boston

Twitter | YouTubeLinkedIn | Articles

27 comments:

Unknown said...

Here's what the whistleblower alleges: Balboa Insurance Group, and it’s largest competitor, the market leader Assurant, is in the business of insurance tracking and Force Placed Insurance (aka Lender Placed Insurance, FOH, LPI, etc). What Is Hospital Indemnity Insurance

Jullia said...

I agree with many of the points you have made in this article. If you are looking for web design and development company, visit ProWeb365 web design.

Emma Watson said...
This comment has been removed by the author.
John Hardy said...

Such a great information in this article. This is all about internet. This information is very helpful and useful. Thanks for sharing this one. Now it's time to avail Locksmith Leeds for more information.

James Lavine said...

I really like your blog. The most interesting things are neatly collected. Every now and then I go to look and wonder. leather biker jacket

David Clark said...

If you've been following along with the tutorial, and take my course online for me you've probably seen the steps involved in installing Ruby and Watir. However, in order to run a browser automation script with Ruby, we'll need to install the chrome driver. This means we'll need to install VS Code as well. This tutorial will show you how to do just that.

Rony James said...

This Cheezy Internet is a great platform for UK students looking for assignment writing help. Their team of experts is highly experienced and ensures quality work at an affordable price. Highly recommended for UK assignment writing service. https://www.ukassignmentshelp.co.uk/

Anonymous said...

Informative post with lots of useful information. Recommended to visit buyessay.org - this is a professional essay writing site that will make your student life easier

Ryan Axel said...
This comment has been removed by the author.
pay someone to do my course online for me said...

Installing Ruby on Windows is an easy process thanks to the RubyInstaller. It provides a simple method to install the language and its associated tools. Watir and Chromedriver are two of the most popular tools used for web automation and testing, respectively. Chocolatey is a package manager that helps you install various software packages quickly and easily. Finally, IDE and VS Code extensions can be used to customize your development environment to meet your specific needs. With these tools, you can have a full-fledged Ruby development environment up and running in no time!

ITFUX24_PC_Laptop_Reparatur said...

If you are facing any kinds of issues with your laptop or pc, just trust ITfux24 and let them handle the tasks for you. The experts have 7+ years of experience with repair service. Take pc reparatur Frankfurt service from them and enjoy the best discount from the starting day!

Laurence J. Shaffer said...

I recently read an article about the adventures in automation and how it's transforming industries. One example was the use of robots in manufacturing, which has not only increased efficiency but also reduced errors. As someone who works in the fashion industry, I can see how automation could be applied to the production of printed polo shirts, for instance. It could help us streamline our processes and reduce waste, while still maintaining the quality of our products. It's exciting to think about how technology can improve our work and make it more sustainable in the long run.





Will Steven said...

It appears that you are specifically interested in King George Traffic Lawyer

Catherine Cromer said...

"The Cheezy Internet: Installing Ruby has become an essential skill in the tech world. However, navigating through the vast web of information can be overwhelming. If you're struggling with programming or need assistance with your statistics assignment, don't fret! Consider seeking reliable 'statistics assignment help' services to ensure you get accurate data analysis and solutions. Stay sharp and savor the journey into the world of Ruby programming!"




Tenzin Jamtsho said...

Keep up the fantastic work! I'm looking forward to reading more from your personal blog and gaining more insights from your unique perspective. Your authenticity is a breath of fresh air in the world of blogging. You can study from crystal clear your skin Hydrafacial In Bangalore

Stephen Foust said...

Navigating the "Cheezy Internet" can be as challenging as the intricacies of filling out a South Carolina real estate license application. In both cases, you need to sift through the noise and find credible sources. Just like choosing the right real estate program is essential for your career, ensuring the authenticity of online information is vital. The digital world, like real estate, demands careful research and discernment to make informed decisions.

John David said...

I appreciate your helpful instructions for installing VS Code, Ruby, Watir, Chromedriver, and other software on Windows 10. It's a necessary step for effective web automation. In a similar spirit, I'd love to see a manual for setting up CISCO7206VXR - Cisco 7206Vxr 6-Slot Chassis Power Supply (W/O Slot Covers) in network infrastructure configurations. Integrating and managing power supplies are essential components of keeping a network reliable and effective. Your knowledge of how to guide through such settings would be quite helpful.

Melvin Rasmussen said...

The Cheezy Internet" surely brings to mind a world of cheesy memes and online humor. But when it's time to satisfy your appetite offline, exploring "Best Pizza Deals in Multan" can be a treat for your taste buds. Just like the internet, Multan's pizza options offer a wide array of flavors and choices. It's all about balancing the digital and culinary worlds for a truly satisfying experience

Henry John said...

Thanks for sharing your insights on setting up Ruby, Watir, Chromedriver, and VS Code on Windows 10! It's a valuable guide for fellow tech enthusiasts. While my focus is on exploring the 57-1000115-01 Transceiver Module, I appreciate your expertise in making these complex installations more accessible to the community. Your post is a great resource for those looking to dive into the world of programming and web automation. Keep up the fantastic work!

Lunajohnson said...

Oh, Such a shocking, and I actually really love this post. It's so good and wonderful. I believe that you stay to do such types of posts like this in the future also

Everything You Need to Know About White Topaz Jewelry

Im Propriety said...

That is really helpful
why is my girlfriend so beautiful

KirstenSmallT said...

Arrested for DUI in Virginia? Our skilled Dui Lawyer Alexandria VA will help you to clear your records.

shofialisa said...

"Stories for Software QA Engineers shifting from manual to automated testing" is a valuable resource aimed at guiding and empowering Quality Assurance (QA) professionals in the transition from manual to automated testing methodologies. This collection of stories offers insights, best practices, and real-world examples that can help QA engineers navigate the challenges and complexities of adopting automated testing tools and practices. separation agreement virginia

Sarah Jonas said...

Embarking on the exciting journey of Adventures in Automation has been a game-changer for me! Streamlining tasks effortlessly has become a reality. Speaking of seamless experiences, don't forget to enhance your tech arsenal with convenience – consider to buy iPhone 13 Wallet. Its sleek design and practicality make it a must-have companion for your automated lifestyle.

landscape said...

Thanks you for sharing such awesome content with us. It's worth reading. If you take pride in owning a Mercedes-Benz, you undoubtedly appreciate the allure of this renowned German brand. Mercedes-Benz vehicles are celebrated for their exceptional performance, luxurious features, and elegant design. However, like any vehicle, Mercedes-Benz cars may require replacement parts over time. Whether it’s for routine maintenance or unexpected repairs, the cost of new OEM (Original Equipment Manufacturer) parts can strain your finances. This is where high-quality Mercedes-Benz Used Parts come into play.

Thots Lifes said...

Very informative post thanks for share

TR SKIN said...

I’ve been feeling a bit overwhelmed lately, and the idea of using journaling as a tool for clarity seems like exactly what I need. TR SKIN