Showing posts with label Geb. Show all posts
Showing posts with label Geb. Show all posts

November 17, 2016

Testing The-Internet with Geb + Groovy + Spock: How did Yeoman set up the tests to run in Gradle?

Part 3 of 5. Need to read from the beginning

For the past few weeks, we've been examining in this blog how to build an automation framework with Geb + the Groovy Language + the Spock Framework, something I have been experimenting with in my new job as a Software Engineer in Test.

One of the developers at my workplace putting together a Geb + Groovy project heard about Yeoman, an open-source tooling application sponsored by the Google Chrome Developer Relations team. This series of blog posts have been examining the software design tool.

Yeoman creates the basic scaffolding for your projects, right out of the box. Instead of re-inventing the wheel, a basic template for the project is produced, depending on what Yeoman generator we picked.

We are using Chris Hluchan's Geb Generator. We will be testing against Dave Haeffner's site, The-Internet, at https://the-internet.herokuapp.com/, taking a look at his Login Page.


Examining the Build.Gradle Configuration File 


If you don't wish to install and configure Node.js, update npm, install and configure Yeoman, and install and configure the Geb Generator, I took the source code that was generated, and placed it as-is on my GitHub site.

Here's an original name! "Geb Project Generated By Yo".

We will be kicking off a few of their built in tests, and examine the build.gradle file and surrounding files to see how they are kicked off.

The next blog article we will be starting to look at the tests themselves. For now, we are focusing on...

Setting Up The Build.Gradle File

When we explored setting up a WebDriver development environment a few months ago, we talked about how, instead of using Maven to handle third-party dependencies, such as ChromeDriver we were going to be looking at Gradle.

October 19, 2016

Testing The-Internet with Geb + Groovy + Spock: Installing Yeoman and the Geb Generator

Part 2 of 5. Need to read from the beginning

To get more familiar with the Geb Framework + Groovy Language + Spock Framework, I was planning on figuring out how to automate Dave Haeffner's Login page on his test site, The-Internet.

A few days ago, I talked a bit about scaffolding a project, laying out the basic groundwork, and the history of Yeoman.io. With this blog post, we will walk a user through downloading and installing Yeoman through the Node Package Manager.

The installation will be done on the command line: the Mac's Terminal or the Windows Command Prompt.


We will be using a Geb Generator created by Chris Hluchan ( LinkedIn ), a Software Engineer at Google, formerly at Oracle.

You can take a look at the generator’s source code on GitHub at https://github.com/chluchan/generator-geb#readme

We will be borrowing heavily from "Let's Scaffold a Web App" written by Mehdy Dara ( Github: zckers ).

Want to see what the boilerplate source code the Geb generator produces? I have uploaded it to my GitHub site at https://github.com/tjmaher/geb_project_generated_by_yo .

The next few blog posts, we will be comparing that to the official Geb + Groovy + Spock Framework documentation to figure out how it works.

First, we need to figure out how to install everything.

October 18, 2016

Testing The-Internet with Geb + Groovy + Spock: About Yeoman, scaffolding, and other build tools

Have you ever needed to set up a brand-new project but were not sure where to start? I am like that right now!

For the past week, I have been trying to figure out how I wanted to set up the file and folder structure for a new Geb + Groovy + Gradle + Spock project. I was going to go back to Dave Haeffner's test site, The-Internet ( link ) and take a look at writing a test for his login page:

  • Geb (pronounced "jeb") is a mash-up of jQuery, Selenium WebDriver, with the Page Object Model, Reporting, and taking Snapshots built in. 
  • Groovy is a scripting language language that I covered before in my blog, specifically when talking about using Gradle for build.gradle configurations. 
  • Gradle does a lot more than handle installing third-party dependencies such as Chromedriver when you want to spin up a new Chrome browser on your local machine. With Gradle, you can set up tests to be kicked off on the command line, just waiting to be fed into a continuous integration environment such as Jenkins.  
  • The Spock Framework follows a Given / Then / When / Expect framework found in Cucumber's Gherkin language format that is usually paired with Ruby
But how do I set all these tools up if I want to test ? How to get them all to work together?

Should I just repurpose Sauce Labs Test Framework, Groovy-Geb-Spock-Selenium at https://github.com/saucelabs-sample-test-frameworks/Groovy-Geb-Spock-Selenium?

A new co-worker of mine referred me to a tool he had heard of at a previous job that may help: Yeoman.io.




In the next blog article, we will be borrowing heavily from "Let's Scaffold a Web App" written by Mehdy Dara ( Github: zckers ) to walk through setting up your Mac or PC for Yeoman. We will also walk through installing a Geb Generator for Yeoman created by Chris Hluchan ( LinkedIn ), a Software Engineer at Google, formerly at Oracle. This will set up the project's scaffolding.

Later articles will talk about about:

  • Diving into the scaffolding code that has been generated, figuring out how it works
  • How to set up the Gradle configuration file to be able to run tests in parallel
  • Customizing the scaffolding to work with a login page
  • How Geb works with Selenium WebDriver: entering text, clicking buttons, and capturing web elements in page objects. 
This blog article will talk a bit about the history of the Yeoman tool.