SlideShare a Scribd company logo
1 of 19
Download to read offline
Geb 
very groovy browser automation 
http://www.gebish.org 1 / 19
Agenda 
1. Introduction to Geb 
WebDriver 
Test framework integrations 
Navigation API 
Page objects 
Module objects 
Content DSL 
Multiple Environments 
2. Our project-setup 
2 / 19
Introduction 
Automating the interaction between web browsers and web content 
Acceptance Testing Web Applications 
Screen scraping 
Great documentation: http://www.gebish.org/manual/current/ 
3 / 19
Example 
geb.Browser 
Browser.drive { 
go "http://myapp.com/login" 
$("h1").text() == "Please Login" 
$("form.login"). { 
username = "admin" 
password = "password" 
login().click() 
} 
$("h1").text() == "Admin Section" 
} 
4 / 19
Technology 
WebDriver (support many browsers) 
Groovy (remove java-boilerplate) 
Spock, JUnit or TestNG (easy to integrate with IDE and build systems) 
Navigator API (jQuery-like content selection) 
5 / 19
WebDriver 
Geb builds on the WebDriver browser automation librar 
Geb can work with any browser that WebDriver can 
Geb provides an abstraction layer, but you can access WebDriver directly 
Geb never talks to the actual browser. 
You need specific driver for each browser you want to work with: 
< > 
< >org.seleniumhq.selenium</ > 
< >selenium-firefox-driver</ > 
< >2.20.0</ > 
</ > 
6 / 19
Test framework integration 
Geb works with existing popular tools like Spock, JUnit, TestNG and 
Cucumber. 
You pick what you like; but Geb encurages Spock. 
7 / 19
Spock example 
geb.spock.GebSpec 
{ 
"first result for wikipedia search should be wikipedia"() { 
given: 
to GoogleHomePage 
expect: 
at GoogleHomePage 
when: 
search.field.value("wikipedia") 
then: 
waitFor { at GoogleResultsPage } 
} 
} 
More about Spock @ https://code.google.com/p/spock/ 8 / 19
Navigator API 
Inspired by jQuery. 
Content is selected via the $ function, which returns a Navigator object 
Makes it super easy to select content 
// match all 'div' elements on the page 
$("div") 
// match the first 'div' element on the page 
$("div", 0) 
// match all 'div' elements with a title attribute value of 'section' 
$("div", title: "section") 
// The parent of the first paragraph 
$("p", 0).parent() 
//<div>foo</div> 
$("div", text: "foo") 
// Using patterns 
$("p", text: ~/p./).size() == 2 
$("p", text: startsWith("p")).size() == 2 
http://www.gebish.org/manual/current/intro.html#the_jquery_ish_navigator_api 9 / 19
Page Objects 
Less fragile code with better abstractions and modelling 
Promotes resuse 
Makes it easier to write tests 
Pages (and modules) can be arranged in inheritance hierarchies. 
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. (webdriver...) 
10 / 19
Page Objects: example 
{ 
url = "/login" 
at = { title == "Login to our super page" } 
content = { 
loginButton(to: AdminPage) { $("input", type: "submit", name: "login") } 
} 
} 
{ 
at = { 
assert $("h1").text() == "Admin Page" 
} 
} 
Browser.drive { 
to LoginPage 
loginButton.click() 
at AdminPage 
} 
to changes the browser’s page instance. 
click on login-button changes page to the "Admin page" 
at explicitly asserts that we are on the expected page 
11 / 19
Module Objects 
Reusable fragments that can be used across pages 
Useful for modelling things like UI widgets that are used across multiple 
pages 
We can define a Navigator context when including the module in a Page. 
Module will then only see "its own part" of the dom via the navigator api 
12 / 19
Module Objects: example 
{ 
content = { 
button { $("input", type: "submit") } 
} 
} 
{ 
content = { 
theModule { module ExampleModule } 
} 
} 
Browser.drive { 
to ExamplePage 
theModule.button.click() 
} 
13 / 19
Content DSL 
Content definitions can build upon each other. 
Content definitions are actually templates. 
{ 
content = { 
results { $("li.g") } 
result { i -> results[i] } 
resultLink { i -> result(i).find("a.l", 0) } 
firstResultLink { resultLink(0) } 
} 
} 
Optional Content 
{ 
content = { 
errorMsg(required: ) { $("p.errorMsg") } 
} 
} 
14 / 19
Dynamic content 
{ 
content = { 
linkTotrigger {$("a"} 
awesomeContainer(required: ) { $("div.awesome") } 
} 
} 
Browser.drive { 
to DynamicPage 
linkTotrigger.click() 
waitFor { awesomeContainer } 
} 
By default, it will look for it every 100ms for 5s before giving up. 
15 / 19
Multiple Environments 
The Groovy ConfigSlurper mechanism has built in support for 
environment sensitive configuration 
system property to determine the environment to use 
remoteDriver = {..} 
driver = { FirefoxDriver() } 
baseUrl = "http://iad.finn.no:3002/" 
iadUrl = "http://dev.finn.no" 
environments { 
'dev' { 
baseUrl = "http://dev.finn.no/talent/" 
iadUrl = "http://dev.finn.no" 
driver = remoteDriver 
} 
'prod' { 
baseUrl = "http://www.finn.no/talent/" 
iadUrl = "http://www.finn.no" 
driver = remoteDriver 
} 
} 
16 / 19
Our project-setup 
Kjører tester lokalt mot lokal server 
Kan kjøre tester som en del av maven-bygget 
men valgt å ikke gjøre dette siden vi er avhengig av finndev-login-tjensten 
Sparker i gang en testkjøring mot dev straks en ny artifakt er deployet i 
dev. 
17 / 19
FINN.no :: Testreports 
JUnit-listner that intgrates Geb with http://testreports.finn.no 
Support @Tags annotation 
Gives status and screenshots for each test 
Easy setup with the maven-surfire-plugin 
< > 
< >org.apache.maven.plugins</ > 
< >maven-surefire-plugin</ > 
< >2.16</ > 
< > 
< > 
< >**/*Spec.*</ > 
</ > 
< > 
< >target/test-reports/geb</ > 
< >${artifactId}</ > 
</ > 
< > 
< > 
< >listener</ > 
< >no.finntech.test.report.runner.GebTestReportRunListener</ > 
</ > 
</ > 18 / 19
Demo time 
19 / 19

More Related Content

What's hot

Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKJosé Paumard
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System ServerOpersys inc.
 
Sphinx + robot framework = documentation as result of functional testing
Sphinx + robot framework = documentation as result of functional testingSphinx + robot framework = documentation as result of functional testing
Sphinx + robot framework = documentation as result of functional testingplewicki
 
Angular 4 Data Binding | Two Way Data Binding in Angular 4 | Angular 4 Tutori...
Angular 4 Data Binding | Two Way Data Binding in Angular 4 | Angular 4 Tutori...Angular 4 Data Binding | Two Way Data Binding in Angular 4 | Angular 4 Tutori...
Angular 4 Data Binding | Two Way Data Binding in Angular 4 | Angular 4 Tutori...Edureka!
 
Inside Android's UI
Inside Android's UIInside Android's UI
Inside Android's UIOpersys inc.
 
Dynamic SSL Certificates and Other New Features in NGINX Plus R18 and NGINX O...
Dynamic SSL Certificates and Other New Features in NGINX Plus R18 and NGINX O...Dynamic SSL Certificates and Other New Features in NGINX Plus R18 and NGINX O...
Dynamic SSL Certificates and Other New Features in NGINX Plus R18 and NGINX O...NGINX, Inc.
 
From Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdfFrom Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdfJosé Paumard
 
The GPS Architecture on Android
The GPS Architecture on AndroidThe GPS Architecture on Android
The GPS Architecture on AndroidPing-Chin Huang
 
Introduction to VueJS & Vuex
Introduction to VueJS & VuexIntroduction to VueJS & Vuex
Introduction to VueJS & VuexBernd Alter
 
Pentesting Modern Web Apps: A Primer
Pentesting Modern Web Apps: A PrimerPentesting Modern Web Apps: A Primer
Pentesting Modern Web Apps: A PrimerBrian Hysell
 
ノンプログラマーのためのjQuery入門
ノンプログラマーのためのjQuery入門ノンプログラマーのためのjQuery入門
ノンプログラマーのためのjQuery入門Hayato Mizuno
 
SUSE shim and things related to it
SUSE shim and things related to itSUSE shim and things related to it
SUSE shim and things related to itSUSE Labs Taipei
 
clean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionclean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionsaber tabatabaee
 

What's hot (20)

Express JS
Express JSExpress JS
Express JS
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UK
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System Server
 
Flask Basics
Flask BasicsFlask Basics
Flask Basics
 
Golang
GolangGolang
Golang
 
Logging system of Android
Logging system of AndroidLogging system of Android
Logging system of Android
 
Sphinx + robot framework = documentation as result of functional testing
Sphinx + robot framework = documentation as result of functional testingSphinx + robot framework = documentation as result of functional testing
Sphinx + robot framework = documentation as result of functional testing
 
Angular 4 Data Binding | Two Way Data Binding in Angular 4 | Angular 4 Tutori...
Angular 4 Data Binding | Two Way Data Binding in Angular 4 | Angular 4 Tutori...Angular 4 Data Binding | Two Way Data Binding in Angular 4 | Angular 4 Tutori...
Angular 4 Data Binding | Two Way Data Binding in Angular 4 | Angular 4 Tutori...
 
Inside Android's UI
Inside Android's UIInside Android's UI
Inside Android's UI
 
Dynamic SSL Certificates and Other New Features in NGINX Plus R18 and NGINX O...
Dynamic SSL Certificates and Other New Features in NGINX Plus R18 and NGINX O...Dynamic SSL Certificates and Other New Features in NGINX Plus R18 and NGINX O...
Dynamic SSL Certificates and Other New Features in NGINX Plus R18 and NGINX O...
 
From Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdfFrom Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdf
 
The GPS Architecture on Android
The GPS Architecture on AndroidThe GPS Architecture on Android
The GPS Architecture on Android
 
Introduction to VueJS & Vuex
Introduction to VueJS & VuexIntroduction to VueJS & Vuex
Introduction to VueJS & Vuex
 
Angular routing
Angular routingAngular routing
Angular routing
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
Pentesting Modern Web Apps: A Primer
Pentesting Modern Web Apps: A PrimerPentesting Modern Web Apps: A Primer
Pentesting Modern Web Apps: A Primer
 
ノンプログラマーのためのjQuery入門
ノンプログラマーのためのjQuery入門ノンプログラマーのためのjQuery入門
ノンプログラマーのためのjQuery入門
 
MongoDB and Node.js
MongoDB and Node.jsMongoDB and Node.js
MongoDB and Node.js
 
SUSE shim and things related to it
SUSE shim and things related to itSUSE shim and things related to it
SUSE shim and things related to it
 
clean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionclean code book summary - uncle bob - English version
clean code book summary - uncle bob - English version
 

Viewers also liked

Cloud browser testing with Gradle and Geb
Cloud browser testing with Gradle and GebCloud browser testing with Gradle and Geb
Cloud browser testing with Gradle and GebDavid Carr
 
Java beyond Java - from the language to platform
Java beyond Java - from the language to platformJava beyond Java - from the language to platform
Java beyond Java - from the language to platformNaresha K
 
Design Patterns from 10K feet
Design Patterns from 10K feetDesign Patterns from 10K feet
Design Patterns from 10K feetNaresha K
 
Better Selenium Tests with Geb - Selenium Conf 2014
Better Selenium Tests with Geb - Selenium Conf 2014Better Selenium Tests with Geb - Selenium Conf 2014
Better Selenium Tests with Geb - Selenium Conf 2014Naresha K
 

Viewers also liked (7)

Cloud browser testing with Gradle and Geb
Cloud browser testing with Gradle and GebCloud browser testing with Gradle and Geb
Cloud browser testing with Gradle and Geb
 
Java beyond Java - from the language to platform
Java beyond Java - from the language to platformJava beyond Java - from the language to platform
Java beyond Java - from the language to platform
 
Design Patterns from 10K feet
Design Patterns from 10K feetDesign Patterns from 10K feet
Design Patterns from 10K feet
 
Better Selenium Tests with Geb - Selenium Conf 2014
Better Selenium Tests with Geb - Selenium Conf 2014Better Selenium Tests with Geb - Selenium Conf 2014
Better Selenium Tests with Geb - Selenium Conf 2014
 
What makes Geb groovy?
What makes Geb groovy?What makes Geb groovy?
What makes Geb groovy?
 
Geb with spock
Geb with spockGeb with spock
Geb with spock
 
Bike To Work Presentation
Bike To Work PresentationBike To Work Presentation
Bike To Work Presentation
 

Similar to Geb presentation

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
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!David Gibbons
 
BlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorksBlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorksmwbrooks
 
Single Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StorySingle Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StoryKon Soulianidis
 
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
 
Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2Filippo Matteo Riggio
 
Grails Plugins(Console, DB Migration, Asset Pipeline and Remote pagination)
Grails Plugins(Console, DB Migration, Asset Pipeline and Remote pagination)Grails Plugins(Console, DB Migration, Asset Pipeline and Remote pagination)
Grails Plugins(Console, DB Migration, Asset Pipeline and Remote pagination)NexThoughts Technologies
 
Writing automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjectsWriting automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjectsLeticia Rss
 
Google App Engine with Gaelyk
Google App Engine with GaelykGoogle App Engine with Gaelyk
Google App Engine with GaelykChoong Ping Teo
 
Pragmatic Browser Automation with Geb - GIDS 2015
Pragmatic Browser Automation with Geb - GIDS 2015Pragmatic Browser Automation with Geb - GIDS 2015
Pragmatic Browser Automation with Geb - GIDS 2015Naresha K
 
Modular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSModular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSGunnar Hillert
 

Similar to Geb presentation (20)

End-to-end testing with geb
End-to-end testing with gebEnd-to-end testing with geb
End-to-end testing with 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_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
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
 
BlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorksBlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorks
 
Single Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StorySingle Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle Story
 
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
 
Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 
Grails Plugins(Console, DB Migration, Asset Pipeline and Remote pagination)
Grails Plugins(Console, DB Migration, Asset Pipeline and Remote pagination)Grails Plugins(Console, DB Migration, Asset Pipeline and Remote pagination)
Grails Plugins(Console, DB Migration, Asset Pipeline and Remote pagination)
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
 
WebGUI Developers Workshop
WebGUI Developers WorkshopWebGUI Developers Workshop
WebGUI Developers Workshop
 
Writing automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjectsWriting automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjects
 
Google App Engine with Gaelyk
Google App Engine with GaelykGoogle App Engine with Gaelyk
Google App Engine with Gaelyk
 
Pragmatic Browser Automation with Geb - GIDS 2015
Pragmatic Browser Automation with Geb - GIDS 2015Pragmatic Browser Automation with Geb - GIDS 2015
Pragmatic Browser Automation with Geb - GIDS 2015
 
Modular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSModular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJS
 

Recently uploaded

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 

Recently uploaded (20)

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 

Geb presentation

  • 1. Geb very groovy browser automation http://www.gebish.org 1 / 19
  • 2. Agenda 1. Introduction to Geb WebDriver Test framework integrations Navigation API Page objects Module objects Content DSL Multiple Environments 2. Our project-setup 2 / 19
  • 3. Introduction Automating the interaction between web browsers and web content Acceptance Testing Web Applications Screen scraping Great documentation: http://www.gebish.org/manual/current/ 3 / 19
  • 4. Example geb.Browser Browser.drive { go "http://myapp.com/login" $("h1").text() == "Please Login" $("form.login"). { username = "admin" password = "password" login().click() } $("h1").text() == "Admin Section" } 4 / 19
  • 5. Technology WebDriver (support many browsers) Groovy (remove java-boilerplate) Spock, JUnit or TestNG (easy to integrate with IDE and build systems) Navigator API (jQuery-like content selection) 5 / 19
  • 6. WebDriver Geb builds on the WebDriver browser automation librar Geb can work with any browser that WebDriver can Geb provides an abstraction layer, but you can access WebDriver directly Geb never talks to the actual browser. You need specific driver for each browser you want to work with: < > < >org.seleniumhq.selenium</ > < >selenium-firefox-driver</ > < >2.20.0</ > </ > 6 / 19
  • 7. Test framework integration Geb works with existing popular tools like Spock, JUnit, TestNG and Cucumber. You pick what you like; but Geb encurages Spock. 7 / 19
  • 8. Spock example geb.spock.GebSpec { "first result for wikipedia search should be wikipedia"() { given: to GoogleHomePage expect: at GoogleHomePage when: search.field.value("wikipedia") then: waitFor { at GoogleResultsPage } } } More about Spock @ https://code.google.com/p/spock/ 8 / 19
  • 9. Navigator API Inspired by jQuery. Content is selected via the $ function, which returns a Navigator object Makes it super easy to select content // match all 'div' elements on the page $("div") // match the first 'div' element on the page $("div", 0) // match all 'div' elements with a title attribute value of 'section' $("div", title: "section") // The parent of the first paragraph $("p", 0).parent() //<div>foo</div> $("div", text: "foo") // Using patterns $("p", text: ~/p./).size() == 2 $("p", text: startsWith("p")).size() == 2 http://www.gebish.org/manual/current/intro.html#the_jquery_ish_navigator_api 9 / 19
  • 10. Page Objects Less fragile code with better abstractions and modelling Promotes resuse Makes it easier to write tests Pages (and modules) can be arranged in inheritance hierarchies. 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. (webdriver...) 10 / 19
  • 11. Page Objects: example { url = "/login" at = { title == "Login to our super page" } content = { loginButton(to: AdminPage) { $("input", type: "submit", name: "login") } } } { at = { assert $("h1").text() == "Admin Page" } } Browser.drive { to LoginPage loginButton.click() at AdminPage } to changes the browser’s page instance. click on login-button changes page to the "Admin page" at explicitly asserts that we are on the expected page 11 / 19
  • 12. Module Objects Reusable fragments that can be used across pages Useful for modelling things like UI widgets that are used across multiple pages We can define a Navigator context when including the module in a Page. Module will then only see "its own part" of the dom via the navigator api 12 / 19
  • 13. Module Objects: example { content = { button { $("input", type: "submit") } } } { content = { theModule { module ExampleModule } } } Browser.drive { to ExamplePage theModule.button.click() } 13 / 19
  • 14. Content DSL Content definitions can build upon each other. Content definitions are actually templates. { content = { results { $("li.g") } result { i -> results[i] } resultLink { i -> result(i).find("a.l", 0) } firstResultLink { resultLink(0) } } } Optional Content { content = { errorMsg(required: ) { $("p.errorMsg") } } } 14 / 19
  • 15. Dynamic content { content = { linkTotrigger {$("a"} awesomeContainer(required: ) { $("div.awesome") } } } Browser.drive { to DynamicPage linkTotrigger.click() waitFor { awesomeContainer } } By default, it will look for it every 100ms for 5s before giving up. 15 / 19
  • 16. Multiple Environments The Groovy ConfigSlurper mechanism has built in support for environment sensitive configuration system property to determine the environment to use remoteDriver = {..} driver = { FirefoxDriver() } baseUrl = "http://iad.finn.no:3002/" iadUrl = "http://dev.finn.no" environments { 'dev' { baseUrl = "http://dev.finn.no/talent/" iadUrl = "http://dev.finn.no" driver = remoteDriver } 'prod' { baseUrl = "http://www.finn.no/talent/" iadUrl = "http://www.finn.no" driver = remoteDriver } } 16 / 19
  • 17. Our project-setup Kjører tester lokalt mot lokal server Kan kjøre tester som en del av maven-bygget men valgt å ikke gjøre dette siden vi er avhengig av finndev-login-tjensten Sparker i gang en testkjøring mot dev straks en ny artifakt er deployet i dev. 17 / 19
  • 18. FINN.no :: Testreports JUnit-listner that intgrates Geb with http://testreports.finn.no Support @Tags annotation Gives status and screenshots for each test Easy setup with the maven-surfire-plugin < > < >org.apache.maven.plugins</ > < >maven-surefire-plugin</ > < >2.16</ > < > < > < >**/*Spec.*</ > </ > < > < >target/test-reports/geb</ > < >${artifactId}</ > </ > < > < > < >listener</ > < >no.finntech.test.report.runner.GebTestReportRunListener</ > </ > </ > 18 / 19
  • 19. Demo time 19 / 19