Talking testing, agile and automation... and anything else.



21
Mar 14

I Cannot Abide QA Politics

If you write a blog about testing and use the term “automated checks” in a post, I will look the other way. If you use it twice, I might just roll my eyes and stop reading. But if you use it three or four times in a single post, I’m unsubscribing from your blog forever.

Plusone Linkedin Facebook Twitter Digg Email

10
Mar 14

Screencast: Creating Your First Test In Geb

In this screencast, I walk you through writing your first test using Geb and Spock. We’ll create a page object and a spec (test), and then run our new test on multiple browsers.

If you’re just getting started, you might want to take a peek at my Geb Quick Start and Project Overview screencasts.

Plusone Linkedin Facebook Twitter Digg Email

08
Mar 14

Screencast: Geb Automation Quick Start

I created a screencast that demonstrates how to quickly get up and running with Geb. This demo assumes you have installed a Java JDK, IntelliJ CE and Safari, and we’ll make use of my geb-example project, available on GitHub.

And once you’re up and running, have a look at my Project Overview screencast…

Plusone Linkedin Facebook Twitter Digg Email

23
Feb 14

Customize Page Navigation By Overriding Geb’s getPageUrl()

gebGeb’s page object pattern offers the ability to set a url for a page, that allows you to navigate directly to a page. The url is used when calling the to() method (eg. to myPage).

An application I’m working on includes dynamic elements in its urls; the urls contain a session token, and can include a return page, and/or various content IDs. This makes it essentially impossible to navigate directly to the page. And unless you’re testing app navigation, it’s better to navigate directly. It keeps your code clean and helps mitigate brittleness.

The solution I’ve come up with is to parse the current url and use it to navigate directly to my pages. To do this, I needed to override Geb’s getPageUrl() (thanks to the Geb user group on this!).

BasePage.groovy

In my example above, we override Geb’s getPageUrl with our own getPageUrl, added to a BasePage, that we’ll extend in our page object. In this new getPageUrl, we want to replace the page name in the url (eg. http://localhost/html#/PAGENAME/…). To do this we grab the current url and just replace the current page name with the target page. All the other elements in the url should be correct.

Now we also need to make sure normal pages continue to operate, so we first test to see if pageName property exists in the page. If not, we execute Geb’s normal url code. To get the target pageName, we add it as a static property to the page (instead of url), named pageName. The code would looke something like this:

MyPage.groovy

Now we can simply call to MyPage as you would with a page with a normal url. Not too shabby!

Plusone Linkedin Facebook Twitter Digg Email

01
Feb 14

A Better Way To Handle Checkboxes in Geb

checkboxGeb is a great automation tool with a lean API but in some cases, perhaps a bit too lean. Case-in-point, checkboxes. Here’s how you handle checkboxes in Geb:

Not the end of the world but IMO, not good enough. It doesn’t read overly well and requiring you to know the value of the checkbox to verify it’s checked, is less than ideal. We can do better… by using modules.

Using a module, we can add methods for handling checkboxes, that are, IMO, easier to read and use.

CheckboxModule

Pretty simple; create a module and add four methods to it. Two that let us check or uncheck a checkbox, and two that verify it’s checked or unchecked. Because isChecked() would require knowing the value of the checkbox (lame), we simply check that is not, not checked (yeah, it hurts my head too).

Now we add the module to our page object and then use the methods in a test…

CLSearchResultsPage

CLSearchSpec

As usual, this code is available on GitHub

Plusone Linkedin Facebook Twitter Digg Email