SlideShare a Scribd company logo
1 of 51
Taming Functional Web Testing
with Spock and Geb
Peter Niederwieser, Gradleware
Creator, Spock
Contributor, Geb
InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese and Brazilian
Portuguese)
• Post content from our QCon conferences
• News 15-20 / week
• Articles 3-4 / week
• Presentations (videos) 12-15 / week
• Interviews 2-3 / week
• Books 1 / month
Watch the video with slide
synchronization on InfoQ.com!
http://www.infoq.com/presentations
/testing-spock-geb
Presented at QCon London
www.qconlondon.com
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
The ActorsSpock, Geb, Page Objects
Spock
“Spock is a testing and specification framework for Java and Groovy applications.
What makes it stand out from the crowd is its beautiful and highly expressive
specification language. Thanks to its JUnit runner, Spock is compatible with most
IDEs, build tools, and continuous integration servers. Spock is inspired from JUnit,
RSpec, jMock, Mockito, Groovy, Scala, Vulcans, and other fascinating life forms.
Spock (ctd.)
http://spockframework.org
ASL2 licence
Serving mankind since 2008
Latest releases: 0.7, 1.0-SNAPSHOT
Java + Groovy
JUnit compatible
Loves Geb
Geb
“Geb is a browser automation solution.
It brings together the power of WebDriver, the elegance of jQuery content selection,
the robustness of Page Object modelling and the expressiveness of the Groovy
language.
It can be used for scripting, scraping and general automation — or equally as a
functional/web/acceptance testing solution via integration with testing frameworks
such as Spock, JUnit & TestNG.
Geb (ctd.)
http://gebish.org
ASL2 license
Serving mankind since 2009
Latest releases: 0.7.2, 1.0-SNAPSHOT
Java + Groovy
Use with any test framework
Loves Spock
First-class page objects
Page Objects
“The Page Object pattern represents the screens of your web app as a series of
objects.
Within your web app's UI, there are areas that your tests interact with. A Page Object
simply models these as objects within the test code. This reduces the amount of
duplicated code and means that if the UI changes, the fix need only be applied in one
place.
Demo: Testing
Google Search
WebDriverhttp://seleniumhq.org/projects/webdriver/
WebDriver
Successor to the Selenium project.
Also known as “Selenium 2”.
Sponsored and driven by Google.
Becoming a W3C standard.
http://dvcs.w3.org/hg/webdriver/raw-file/515b648d58ff/webdriver-spec.html
Cross-browser automation
Java based, with many language bindings.
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.*;
WebDriver driver = new FirefoxDriver();
driver.get("http://google.com");
WebElement searchBox = driver.findElement(By.name("q"));
searchBox.sendKeys("webdriver");
driver.findElement(By.name("btnK")).click();
Mobile Browsers
Rapidly improving.
iPad
iPhone
Android
Blackberry
Can use real devices or emulators in most cases.
A headless driver based on (called ) is in progress.PhantomJS GhostDriver
1.
2.
3.
1.
2.
3.
WebDriver
Pros:
Proven solution for cross browser automation
Very active development
Stable API and feature set
Cons:
Verbose
Low level
Not a complete solution
Geb embraces the pros and solve the cons by building on top.
Architecture
WebDriver API
Geb sits on top of WebDriver.
Can access WebDriver API directly if needed.
Only WebDriver talks to the actual browser.
jQueryhttp://jquery.com/
jQuery - write more, do less
jQuery provides an incredibly powerful API for navigating and selecting content.
$("div#footer").prev().children();
CSS based, a whole lot better than XPath.
Geb's inspiration
Geb features a “Navigator API” that is inspired by jQuery.
// This is Geb code, not jQuery JavaScript…
$("div#footer").previous().children()
Geb doesn't aim to emulate jQuery, it just borrows ideas.
Groovyhttp://groovy-lang.org
Dynamic JVM Language
Groovy is…
Compiled, never interpreted
Dynamic, optionally typed
95% Java syntax compatible
Concise, clear and pragmatic
Great for DSLs
Geb & Groovy
Geb uses Groovy's dynamism to remove boilerplate, to achieve pseudo English
.code
to GoogleHomePage
searchFor "Wikipedia"
assert resultName(0) == "Wikipedia"
resultLink(0).click()
at WikipediaPage
Conciseness = improved clarity & improved maintainability.
Navigator APIjQuery inspired content selection/navigation
The $() method
Returns a object.Navigator
General format:
$(«css selector», «index/range», «attribute/text matchers»)
Examples:
$("div") // all divs
$("div", 0) // first div
$("div", 0..2) // first three divs
// The third section heading with text “Geb”
$("h2", 2, id: "section", text: "Geb")
CSS Selectors
Full CSS3 if the target browser supports it.
$("div.some-class p:first[title='something']")
$("ul li a")
$("table tr:nth-child(2n+1) td")
$("div#content p:first-child::first-line")
CSS lookups are .fast
Attribute/Text matching
Can match on attribute values:
//<div foo="bar">
$("div", foo: "bar")
The “text” attribute is special:
//<div>foo</div>
$("div", text: "foo")
Can use Regular Expressions:
//<div>foo</div>
$("div", text: ~/f.+/)
Predicates
Geb supplies some handy predicates:
$("p", text: startsWith("p"))
$("p", class: contains("section"))
$("p", id: endsWith(~/d/))
There are .more of these
Relative Content
$() returns a that allows you to find relative content.Navigator
$("p").previous()
$("p").prevAll()
$("p").next()
$("p").nextAll()
$("p").parent()
$("p").siblings()
$("div").children()
Most of these methods take selectors, indexes and attribute text/matchers too.
$("p").nextAll(".listing")
Pages and
Modules
Content DSL
class GoogleResultsPage extends Page {
static content = {
results { $("li.g") }
result { i -> results[i] }
resultLink { i -> result(i).find("a.l", 0) }
firstResultLink { resultLink(0) }
}
}
Content definitions can upon each other.build
Optional Content
class OptionalPage extends Page {
static content = {
errorMsg(required: false) { $("p.errorMsg") }
}
}
By default, Geb will error if the content you select doesn't exist.
The “ ” option disables this check.required
Dynamic Content
class DynamicPage extends Page {
static content = {
errorMsg(wait: true) { $("p.errorMsg") }
}
}
Geb will wait for some time for this content to appear.
Same semantics as the method that can be used anywhere.waitFor {}
Expensive Content
class ExpensivePage extends Page {
static content = {
results(cache: true) { $("li.results") }
result { results[it] }
}
}
By default, all content is transient.
The option instructs Geb to hold on to the content, avoiding redundantcache
lookups.
Use carefully, can cause problems with dynamic pages.
Modules
Modules can be used for reused content fragments.
class CartInfoModule extends Module {
static content = {
section { $("div.cart-info") }
totalCost { section.find("span.total-cost").toDouble() }
}
}
class HomePage extends Page {
static content = {
cartInfo { module CartInfoModule }
}
}
Modules
They encapsulate detail.
to HomePage
assert cartInfo.totalCost == 10.00
And support reuse…
class AnotherPage extends Page {
static content = {
cartInfo { module CartInfoModule }
}
}
Inheritance
Pages (and modules) can be arranged in inheritance hierarchies.
class Footer extends Module {
static content = {
copyright { $("p.copyright") }
}
}
class StandardPage extends Page {
static content = {
footer { module Footer }
}
}
class FrontPage extends StandardPage {}
The front page will the “footer” content definition.inherit
Feature Tour!More info @ http://gebish.org/manual/current
Form Shortcuts
Geb makes it easy to deal with all form controls. Read and write s likeinput
properties.
Finds first | | with the given name.input select textarea
firstName = "Luke" // write
firstName == "Luke" // read
someCheckbox = true
someSelect = "some option name or value"
someMultiSelect = ["selected1", "selected2"]
Unified API for all element types.
Driver Management
Geb caches the instance (per thread) and shares it across tests.WebDriver
Manages clearing cookies and is configurable.
This can be disabled and tuned.
Configuration Management
Looks for class or file (or class) on classpath.GebConfig GebConfig.groovy
driver = {
new FirefoxDriver()
}
waiting {
timeout = 2
slow { timeout = 100 }
}
reportsDir = "geb-reports"
environments {
chrome { driver = "chrome" }
}
Select environment with .-Dgeb.env=chrome
Adhoc waiting
The method can be used anywhere to wait for any condition to be true.waitFor
Groovy's flexible notion of “truth” makes this powerful.
waitFor { $("p.errorMsg") }.text() == "Error!"
waitFor { $("p.errorMsg").text() } == "Error!"
Waiting options are configurable…
waitFor(timeout: 10, retry: 0.1) { … }
waitFor("fast") { … }
Defaults and named presets controlled by configuration.
Direct Downloading
Examine binary resources easily, with the session state.
go "http://myapp.com/login"
// login
username = "me"
password = "secret"
login().click()
def downloadLink = $("a.pdf-download-link")
// now get the pdf bytes (that requires authentication)
def bytes = downloadBytes(downloadLink.@href)
Also and .downloadStream() downloadText()
JavaScript Interface
<script>
var globalVar;
function globalFunction(arg1) {
…
}
</script>
Can access global JS variables and functions with Groovy code…
js.globalVar = 1
assert js.globalVar == 1
js.globalFunction("the arg")
jQuery Adapter
Geb makes it easy to get a jQuery object for content.
$("input").jquery.keydown()
Useful for simulating interactions that are difficult/unreliable with the WebDriver
API.
The property is a proxy for an equivalent jQuery object in the JS runtime.jquery
Not to be abused!
Frame / Window Support
Jumping to frames temporarily…
withFrame($('#footer')) { assert $('span') == 'frame text' }
Focussing on an open window…
withWindow({ title == "Another Window" }) {
// do some stuff with the window
}
// back to the previous window
Managing opening new windows…
withNewWindow({ $('a').click() }) {
// do some stuff with the new window
}
// back to the previous window
Interaction DSL (Actions)
DSL for building actions…
import static org.openqa.selenium.Keys.*
class SomeClass extends Page {
static content = { someContent { $("div.someContent") } }
}
interact {
keyDown SHIFT
clickAndHold someContent
moveToElement $("div.dropZone")
keyUp SHIFT
release()
}
Builds on top of WebDriver's support.Actions
Remote Browsers
WebDriver can automate remote browsers. This might be a local Windows VM, or
a browser out in the “cloud”.
SauceLabs offer cloud browser infrastructure that Geb can use.
def capabilities = DesiredCapabilities.firefox()
capabilities.setCapability("version", "5")
capabilities.setCapability("platform", Platform.XP)
def url = "http://user:pass@ondemand.saucelabs.com:80/wd/hub"
def sauceLabsDriver = new RemoteWebDriver(
new URL(url), capabilities
)
Q&A
Further Spock Links
Homepage - spockframework.org
Documentation - docs.spockframework.org
Source Code — github.spockframework.org
Forum - forum.spockframework.org
Further Geb Links
Homepage - www.gebish.org
Documentation — www.gebish.org/manual/current
Source Code — github.com/geb/geb
Mailing List — xircles.codehaus.org/projects/geb/lists
Both Spock and Geb will go this year.1.0
Thank YouMay no bugs be with you!
Watch the video with slide synchronization on
InfoQ.com!
http://www.infoq.com/presentations/testing-
spock-geb

More Related Content

What's hot

A Closer Look At React Native
A Closer Look At React NativeA Closer Look At React Native
A Closer Look At React NativeIan Wang
 
Behave manners for ui testing pycon2019
Behave manners for ui testing pycon2019Behave manners for ui testing pycon2019
Behave manners for ui testing pycon2019Panos Christeas
 
Web Performance Part 4 "Client-side performance"
Web Performance Part 4  "Client-side performance"Web Performance Part 4  "Client-side performance"
Web Performance Part 4 "Client-side performance"Binary Studio
 
Lunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and CapybaraLunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and CapybaraMarc Seeger
 
Ci of js and apex using jasmine, phantom js and drone io df14
Ci of js and apex using jasmine, phantom js and drone io   df14Ci of js and apex using jasmine, phantom js and drone io   df14
Ci of js and apex using jasmine, phantom js and drone io df14Kevin Poorman
 
The LAZY Developer's Guide to BDD (with Cucumber)
The LAZY Developer's Guide to BDD (with Cucumber)The LAZY Developer's Guide to BDD (with Cucumber)
The LAZY Developer's Guide to BDD (with Cucumber)Tze Yang Ng
 
Introducing Playwright's New Test Runner
Introducing Playwright's New Test RunnerIntroducing Playwright's New Test Runner
Introducing Playwright's New Test RunnerApplitools
 
Secrets of a Blazor Component Artisan
Secrets of a Blazor Component ArtisanSecrets of a Blazor Component Artisan
Secrets of a Blazor Component ArtisanEd Charbeneau
 
Lessons from a year of building apps with React Native
Lessons from a year of building apps with React NativeLessons from a year of building apps with React Native
Lessons from a year of building apps with React NativeRyan Boland
 
Play Framework on Google App Engine - Productivity Stack
Play Framework on Google App Engine - Productivity StackPlay Framework on Google App Engine - Productivity Stack
Play Framework on Google App Engine - Productivity StackMarcin Stepien
 
Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...
Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...
Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...Max Andersen
 
A tour of React Native
A tour of React NativeA tour of React Native
A tour of React NativeTadeu Zagallo
 
The Gist of React Native
The Gist of React NativeThe Gist of React Native
The Gist of React NativeDarren Cruse
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React NativeWaqqas Jabbar
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with CucumberBrandon Keepers
 
Build Your Own CMS with Apache Sling
Build Your Own CMS with Apache SlingBuild Your Own CMS with Apache Sling
Build Your Own CMS with Apache SlingBob Paulin
 

What's hot (20)

Behavior Driven Development Testing (BDD)
Behavior Driven Development Testing (BDD)Behavior Driven Development Testing (BDD)
Behavior Driven Development Testing (BDD)
 
A Closer Look At React Native
A Closer Look At React NativeA Closer Look At React Native
A Closer Look At React Native
 
Behave manners for ui testing pycon2019
Behave manners for ui testing pycon2019Behave manners for ui testing pycon2019
Behave manners for ui testing pycon2019
 
Web Performance Part 4 "Client-side performance"
Web Performance Part 4  "Client-side performance"Web Performance Part 4  "Client-side performance"
Web Performance Part 4 "Client-side performance"
 
Lunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and CapybaraLunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and Capybara
 
Ci of js and apex using jasmine, phantom js and drone io df14
Ci of js and apex using jasmine, phantom js and drone io   df14Ci of js and apex using jasmine, phantom js and drone io   df14
Ci of js and apex using jasmine, phantom js and drone io df14
 
The LAZY Developer's Guide to BDD (with Cucumber)
The LAZY Developer's Guide to BDD (with Cucumber)The LAZY Developer's Guide to BDD (with Cucumber)
The LAZY Developer's Guide to BDD (with Cucumber)
 
Introducing Playwright's New Test Runner
Introducing Playwright's New Test RunnerIntroducing Playwright's New Test Runner
Introducing Playwright's New Test Runner
 
Secrets of a Blazor Component Artisan
Secrets of a Blazor Component ArtisanSecrets of a Blazor Component Artisan
Secrets of a Blazor Component Artisan
 
Lessons from a year of building apps with React Native
Lessons from a year of building apps with React NativeLessons from a year of building apps with React Native
Lessons from a year of building apps with React Native
 
Play Framework on Google App Engine - Productivity Stack
Play Framework on Google App Engine - Productivity StackPlay Framework on Google App Engine - Productivity Stack
Play Framework on Google App Engine - Productivity Stack
 
Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...
Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...
Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...
 
Introduction To Grails
Introduction To GrailsIntroduction To Grails
Introduction To Grails
 
A tour of React Native
A tour of React NativeA tour of React Native
A tour of React Native
 
The Gist of React Native
The Gist of React NativeThe Gist of React Native
The Gist of React Native
 
Gradle
GradleGradle
Gradle
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
Gradle by Example
Gradle by ExampleGradle by Example
Gradle by Example
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with Cucumber
 
Build Your Own CMS with Apache Sling
Build Your Own CMS with Apache SlingBuild Your Own CMS with Apache Sling
Build Your Own CMS with Apache Sling
 

Viewers also liked

Smarter Testing With Spock
Smarter Testing With SpockSmarter Testing With Spock
Smarter Testing With SpockIT Weekend
 
Idiomatic spock
Idiomatic spockIdiomatic spock
Idiomatic spockGR8Conf
 
Unit testing with Spock Framework
Unit testing with Spock FrameworkUnit testing with Spock Framework
Unit testing with Spock FrameworkEugene Dvorkin
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEBHoward Lewis Ship
 
Westrich spock-assets-gum
Westrich spock-assets-gumWestrich spock-assets-gum
Westrich spock-assets-gumBrian Westrich
 
Spock - the next stage of unit testing
Spock - the next stage of unit testingSpock - the next stage of unit testing
Spock - the next stage of unit testingjugkaraganda
 
Qa engineer performance appraisal
Qa engineer performance appraisalQa engineer performance appraisal
Qa engineer performance appraisalcampbelljonny439
 
Testing a 2D Platformer with Spock
Testing a 2D Platformer with SpockTesting a 2D Platformer with Spock
Testing a 2D Platformer with SpockAlexander Tarlinder
 
Fabulous Tests on Spock and Groovy
Fabulous Tests on Spock and GroovyFabulous Tests on Spock and Groovy
Fabulous Tests on Spock and GroovyYaroslav Pernerovsky
 
Spock Extensions Anatomy
Spock Extensions AnatomySpock Extensions Anatomy
Spock Extensions AnatomyEvgeny Goldin
 

Viewers also liked (12)

Spock framework
Spock frameworkSpock framework
Spock framework
 
Smarter Testing With Spock
Smarter Testing With SpockSmarter Testing With Spock
Smarter Testing With Spock
 
Idiomatic spock
Idiomatic spockIdiomatic spock
Idiomatic spock
 
Unit testing with Spock Framework
Unit testing with Spock FrameworkUnit testing with Spock Framework
Unit testing with Spock Framework
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEB
 
Westrich spock-assets-gum
Westrich spock-assets-gumWestrich spock-assets-gum
Westrich spock-assets-gum
 
TDD with Spock @xpdays_ua
TDD with Spock @xpdays_uaTDD with Spock @xpdays_ua
TDD with Spock @xpdays_ua
 
Spock - the next stage of unit testing
Spock - the next stage of unit testingSpock - the next stage of unit testing
Spock - the next stage of unit testing
 
Qa engineer performance appraisal
Qa engineer performance appraisalQa engineer performance appraisal
Qa engineer performance appraisal
 
Testing a 2D Platformer with Spock
Testing a 2D Platformer with SpockTesting a 2D Platformer with Spock
Testing a 2D Platformer with Spock
 
Fabulous Tests on Spock and Groovy
Fabulous Tests on Spock and GroovyFabulous Tests on Spock and Groovy
Fabulous Tests on Spock and Groovy
 
Spock Extensions Anatomy
Spock Extensions AnatomySpock Extensions Anatomy
Spock Extensions Anatomy
 

Similar to Taming Functional Web Testing with Spock and Geb

Agile NCR 2013 - Gaurav Bansal- web_automation
Agile NCR 2013 - Gaurav Bansal- web_automationAgile NCR 2013 - Gaurav Bansal- web_automation
Agile NCR 2013 - Gaurav Bansal- web_automationAgileNCR2013
 
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect ModelComprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect ModelvodQA
 
Jquery Plugin
Jquery PluginJquery Plugin
Jquery PluginRavi Mone
 
greach 2014 marco vermeulen bdd using cucumber jvm and groovy
greach 2014 marco vermeulen bdd using cucumber jvm and groovygreach 2014 marco vermeulen bdd using cucumber jvm and groovy
greach 2014 marco vermeulen bdd using cucumber jvm and groovyJessie Evangelista
 
GQuery a jQuery clone for Gwt, RivieraDev 2011
GQuery a jQuery clone for Gwt, RivieraDev 2011GQuery a jQuery clone for Gwt, RivieraDev 2011
GQuery a jQuery clone for Gwt, RivieraDev 2011Manuel Carrasco Moñino
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Enginecatherinewall
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instrumentsArtem Nagornyi
 
Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneAndres Almiray
 
An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersKostas Saidis
 
T 0230 Google Wave Powered By Gwt
T 0230 Google Wave Powered By GwtT 0230 Google Wave Powered By Gwt
T 0230 Google Wave Powered By Gwtsupertoy2015
 
In the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleIn the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleSkills Matter
 
Plugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsPlugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsSadayuki Furuhashi
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersJavan Rasokat
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest servicesIoan Eugen Stan
 
Learning jQuery made exciting in an interactive session by one of our team me...
Learning jQuery made exciting in an interactive session by one of our team me...Learning jQuery made exciting in an interactive session by one of our team me...
Learning jQuery made exciting in an interactive session by one of our team me...Thinqloud
 
Zepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksZepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksThomas Fuchs
 
JavaScript Misunderstood
JavaScript MisunderstoodJavaScript Misunderstood
JavaScript MisunderstoodBhavya Siddappa
 
Making Chrome Extension with AngularJS
Making Chrome Extension with AngularJSMaking Chrome Extension with AngularJS
Making Chrome Extension with AngularJSBen Lau
 

Similar to Taming Functional Web Testing with Spock and Geb (20)

Agile NCR 2013 - Gaurav Bansal- web_automation
Agile NCR 2013 - Gaurav Bansal- web_automationAgile NCR 2013 - Gaurav Bansal- web_automation
Agile NCR 2013 - Gaurav Bansal- web_automation
 
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect ModelComprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
 
Jquery Plugin
Jquery PluginJquery Plugin
Jquery Plugin
 
greach 2014 marco vermeulen bdd using cucumber jvm and groovy
greach 2014 marco vermeulen bdd using cucumber jvm and groovygreach 2014 marco vermeulen bdd using cucumber jvm and groovy
greach 2014 marco vermeulen bdd using cucumber jvm and groovy
 
End-to-end testing with geb
End-to-end testing with gebEnd-to-end testing with geb
End-to-end testing with geb
 
GQuery a jQuery clone for Gwt, RivieraDev 2011
GQuery a jQuery clone for Gwt, RivieraDev 2011GQuery a jQuery clone for Gwt, RivieraDev 2011
GQuery a jQuery clone for Gwt, RivieraDev 2011
 
Test Driven In Groovy
Test Driven In GroovyTest Driven In Groovy
Test Driven In Groovy
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instruments
 
Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast Lane
 
An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java Developers
 
T 0230 Google Wave Powered By Gwt
T 0230 Google Wave Powered By GwtT 0230 Google Wave Powered By Gwt
T 0230 Google Wave Powered By Gwt
 
In the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleIn the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: Gradle
 
Plugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsPlugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGems
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
 
Learning jQuery made exciting in an interactive session by one of our team me...
Learning jQuery made exciting in an interactive session by one of our team me...Learning jQuery made exciting in an interactive session by one of our team me...
Learning jQuery made exciting in an interactive session by one of our team me...
 
Zepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksZepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-Frameworks
 
JavaScript Misunderstood
JavaScript MisunderstoodJavaScript Misunderstood
JavaScript Misunderstood
 
Making Chrome Extension with AngularJS
Making Chrome Extension with AngularJSMaking Chrome Extension with AngularJS
Making Chrome Extension with AngularJS
 

More from C4Media

Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoStreaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoC4Media
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileC4Media
 
Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020C4Media
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsC4Media
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No KeeperC4Media
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like OwnersC4Media
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaC4Media
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideC4Media
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDC4Media
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine LearningC4Media
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at SpeedC4Media
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsC4Media
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsC4Media
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerC4Media
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleC4Media
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeC4Media
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereC4Media
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing ForC4Media
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data EngineeringC4Media
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreC4Media
 

More from C4Media (20)

Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoStreaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live Video
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy Mobile
 
Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java Applications
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No Keeper
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like Owners
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate Guide
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CD
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine Learning
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at Speed
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep Systems
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.js
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix Scale
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's Edge
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home Everywhere
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing For
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data Engineering
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 

Recently uploaded

SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 

Recently uploaded (20)

SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 

Taming Functional Web Testing with Spock and Geb

  • 1. Taming Functional Web Testing with Spock and Geb Peter Niederwieser, Gradleware Creator, Spock Contributor, Geb
  • 2. InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations /testing-spock-geb
  • 3. Presented at QCon London www.qconlondon.com Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide
  • 4. The ActorsSpock, Geb, Page Objects
  • 5. Spock “Spock is a testing and specification framework for Java and Groovy applications. What makes it stand out from the crowd is its beautiful and highly expressive specification language. Thanks to its JUnit runner, Spock is compatible with most IDEs, build tools, and continuous integration servers. Spock is inspired from JUnit, RSpec, jMock, Mockito, Groovy, Scala, Vulcans, and other fascinating life forms.
  • 6. Spock (ctd.) http://spockframework.org ASL2 licence Serving mankind since 2008 Latest releases: 0.7, 1.0-SNAPSHOT Java + Groovy JUnit compatible Loves Geb
  • 7. Geb “Geb is a browser automation solution. It brings together the power of WebDriver, the elegance of jQuery content selection, the robustness of Page Object modelling and the expressiveness of the Groovy language. It can be used for scripting, scraping and general automation — or equally as a functional/web/acceptance testing solution via integration with testing frameworks such as Spock, JUnit & TestNG.
  • 8. Geb (ctd.) http://gebish.org ASL2 license Serving mankind since 2009 Latest releases: 0.7.2, 1.0-SNAPSHOT Java + Groovy Use with any test framework Loves Spock First-class page objects
  • 9. Page Objects “The Page Object pattern represents the screens of your web app as a series of objects. Within your web app's UI, there are areas that your tests interact with. A Page Object simply models these as objects within the test code. This reduces the amount of duplicated code and means that if the UI changes, the fix need only be applied in one place.
  • 12. WebDriver Successor to the Selenium project. Also known as “Selenium 2”. Sponsored and driven by Google. Becoming a W3C standard. http://dvcs.w3.org/hg/webdriver/raw-file/515b648d58ff/webdriver-spec.html
  • 13. Cross-browser automation Java based, with many language bindings. import org.openqa.selenium.*; import org.openqa.selenium.firefox.*; WebDriver driver = new FirefoxDriver(); driver.get("http://google.com"); WebElement searchBox = driver.findElement(By.name("q")); searchBox.sendKeys("webdriver"); driver.findElement(By.name("btnK")).click();
  • 14. Mobile Browsers Rapidly improving. iPad iPhone Android Blackberry Can use real devices or emulators in most cases. A headless driver based on (called ) is in progress.PhantomJS GhostDriver
  • 15. 1. 2. 3. 1. 2. 3. WebDriver Pros: Proven solution for cross browser automation Very active development Stable API and feature set Cons: Verbose Low level Not a complete solution Geb embraces the pros and solve the cons by building on top.
  • 17. WebDriver API Geb sits on top of WebDriver. Can access WebDriver API directly if needed. Only WebDriver talks to the actual browser.
  • 19. jQuery - write more, do less jQuery provides an incredibly powerful API for navigating and selecting content. $("div#footer").prev().children(); CSS based, a whole lot better than XPath.
  • 20. Geb's inspiration Geb features a “Navigator API” that is inspired by jQuery. // This is Geb code, not jQuery JavaScript… $("div#footer").previous().children() Geb doesn't aim to emulate jQuery, it just borrows ideas.
  • 22. Dynamic JVM Language Groovy is… Compiled, never interpreted Dynamic, optionally typed 95% Java syntax compatible Concise, clear and pragmatic Great for DSLs
  • 23. Geb & Groovy Geb uses Groovy's dynamism to remove boilerplate, to achieve pseudo English .code to GoogleHomePage searchFor "Wikipedia" assert resultName(0) == "Wikipedia" resultLink(0).click() at WikipediaPage Conciseness = improved clarity & improved maintainability.
  • 24. Navigator APIjQuery inspired content selection/navigation
  • 25. The $() method Returns a object.Navigator General format: $(«css selector», «index/range», «attribute/text matchers») Examples: $("div") // all divs $("div", 0) // first div $("div", 0..2) // first three divs // The third section heading with text “Geb” $("h2", 2, id: "section", text: "Geb")
  • 26. CSS Selectors Full CSS3 if the target browser supports it. $("div.some-class p:first[title='something']") $("ul li a") $("table tr:nth-child(2n+1) td") $("div#content p:first-child::first-line") CSS lookups are .fast
  • 27. Attribute/Text matching Can match on attribute values: //<div foo="bar"> $("div", foo: "bar") The “text” attribute is special: //<div>foo</div> $("div", text: "foo") Can use Regular Expressions: //<div>foo</div> $("div", text: ~/f.+/)
  • 28. Predicates Geb supplies some handy predicates: $("p", text: startsWith("p")) $("p", class: contains("section")) $("p", id: endsWith(~/d/)) There are .more of these
  • 29. Relative Content $() returns a that allows you to find relative content.Navigator $("p").previous() $("p").prevAll() $("p").next() $("p").nextAll() $("p").parent() $("p").siblings() $("div").children() Most of these methods take selectors, indexes and attribute text/matchers too. $("p").nextAll(".listing")
  • 31. Content DSL class GoogleResultsPage extends Page { static content = { results { $("li.g") } result { i -> results[i] } resultLink { i -> result(i).find("a.l", 0) } firstResultLink { resultLink(0) } } } Content definitions can upon each other.build
  • 32. Optional Content class OptionalPage extends Page { static content = { errorMsg(required: false) { $("p.errorMsg") } } } By default, Geb will error if the content you select doesn't exist. The “ ” option disables this check.required
  • 33. Dynamic Content class DynamicPage extends Page { static content = { errorMsg(wait: true) { $("p.errorMsg") } } } Geb will wait for some time for this content to appear. Same semantics as the method that can be used anywhere.waitFor {}
  • 34. Expensive Content class ExpensivePage extends Page { static content = { results(cache: true) { $("li.results") } result { results[it] } } } By default, all content is transient. The option instructs Geb to hold on to the content, avoiding redundantcache lookups. Use carefully, can cause problems with dynamic pages.
  • 35. Modules Modules can be used for reused content fragments. class CartInfoModule extends Module { static content = { section { $("div.cart-info") } totalCost { section.find("span.total-cost").toDouble() } } } class HomePage extends Page { static content = { cartInfo { module CartInfoModule } } }
  • 36. Modules They encapsulate detail. to HomePage assert cartInfo.totalCost == 10.00 And support reuse… class AnotherPage extends Page { static content = { cartInfo { module CartInfoModule } } }
  • 37. Inheritance Pages (and modules) can be arranged in inheritance hierarchies. class Footer extends Module { static content = { copyright { $("p.copyright") } } } class StandardPage extends Page { static content = { footer { module Footer } } } class FrontPage extends StandardPage {} The front page will the “footer” content definition.inherit
  • 38. Feature Tour!More info @ http://gebish.org/manual/current
  • 39. Form Shortcuts Geb makes it easy to deal with all form controls. Read and write s likeinput properties. Finds first | | with the given name.input select textarea firstName = "Luke" // write firstName == "Luke" // read someCheckbox = true someSelect = "some option name or value" someMultiSelect = ["selected1", "selected2"] Unified API for all element types.
  • 40. Driver Management Geb caches the instance (per thread) and shares it across tests.WebDriver Manages clearing cookies and is configurable. This can be disabled and tuned.
  • 41. Configuration Management Looks for class or file (or class) on classpath.GebConfig GebConfig.groovy driver = { new FirefoxDriver() } waiting { timeout = 2 slow { timeout = 100 } } reportsDir = "geb-reports" environments { chrome { driver = "chrome" } } Select environment with .-Dgeb.env=chrome
  • 42. Adhoc waiting The method can be used anywhere to wait for any condition to be true.waitFor Groovy's flexible notion of “truth” makes this powerful. waitFor { $("p.errorMsg") }.text() == "Error!" waitFor { $("p.errorMsg").text() } == "Error!" Waiting options are configurable… waitFor(timeout: 10, retry: 0.1) { … } waitFor("fast") { … } Defaults and named presets controlled by configuration.
  • 43. Direct Downloading Examine binary resources easily, with the session state. go "http://myapp.com/login" // login username = "me" password = "secret" login().click() def downloadLink = $("a.pdf-download-link") // now get the pdf bytes (that requires authentication) def bytes = downloadBytes(downloadLink.@href) Also and .downloadStream() downloadText()
  • 44. JavaScript Interface <script> var globalVar; function globalFunction(arg1) { … } </script> Can access global JS variables and functions with Groovy code… js.globalVar = 1 assert js.globalVar == 1 js.globalFunction("the arg")
  • 45. jQuery Adapter Geb makes it easy to get a jQuery object for content. $("input").jquery.keydown() Useful for simulating interactions that are difficult/unreliable with the WebDriver API. The property is a proxy for an equivalent jQuery object in the JS runtime.jquery Not to be abused!
  • 46. Frame / Window Support Jumping to frames temporarily… withFrame($('#footer')) { assert $('span') == 'frame text' } Focussing on an open window… withWindow({ title == "Another Window" }) { // do some stuff with the window } // back to the previous window Managing opening new windows… withNewWindow({ $('a').click() }) { // do some stuff with the new window } // back to the previous window
  • 47. Interaction DSL (Actions) DSL for building actions… import static org.openqa.selenium.Keys.* class SomeClass extends Page { static content = { someContent { $("div.someContent") } } } interact { keyDown SHIFT clickAndHold someContent moveToElement $("div.dropZone") keyUp SHIFT release() } Builds on top of WebDriver's support.Actions
  • 48. Remote Browsers WebDriver can automate remote browsers. This might be a local Windows VM, or a browser out in the “cloud”. SauceLabs offer cloud browser infrastructure that Geb can use. def capabilities = DesiredCapabilities.firefox() capabilities.setCapability("version", "5") capabilities.setCapability("platform", Platform.XP) def url = "http://user:pass@ondemand.saucelabs.com:80/wd/hub" def sauceLabsDriver = new RemoteWebDriver( new URL(url), capabilities )
  • 49. Q&A Further Spock Links Homepage - spockframework.org Documentation - docs.spockframework.org Source Code — github.spockframework.org Forum - forum.spockframework.org Further Geb Links Homepage - www.gebish.org Documentation — www.gebish.org/manual/current Source Code — github.com/geb/geb Mailing List — xircles.codehaus.org/projects/geb/lists Both Spock and Geb will go this year.1.0
  • 50. Thank YouMay no bugs be with you!
  • 51. Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations/testing- spock-geb