SlideShare une entreprise Scribd logo
1  sur  14
GEB WITH SPOCK
Browser Test automation and
Specification Framework
By Monika Gurram
KickStartPros.com
GEB FEATURES
PRONOUNCED AS “JEB”
 Geb is a browser automation framework written in
Groovy Language.
 Expressiveness and Dynamic nature of Groovy language
makes Geb framework less Code Ceremony.
 Geb uses power of Selenium WebDriver. Cross browser
support.
 Geb provides jQuery-like API for web content selection.
GEB POWER
GEB USES WEBDRIVER & GROOVY DSL
 Selenium WebDriver 2.x cross browser support like IE, FF,
Chrome, Opera & Headless browsers.
 Groovy DSL
to : option defines the page the browser will be sent to if the
content is clicked.
content : descripts the page web elements content.
required : option controls whether or not the content returned by
the definition has to exist or not.
cache: option controls whether or not to evaluate each time the
content is requested. Caching makes tests run fast.
wait : wait for the content using default wait time.
page: option allows the definition of a frame page.
GEB NAVIGATOR API
JQUERY-LIKE API
 Navigator API is jQuery-like API for finding, filtering and
interacting with DOM elements.
 The $ Function for getting DOM elements:
CSS3 Selectors:
 $(«css selector», «index or range»,
«attribute/text matchers»)
 $("div.some-class p:first[title='something']")
Find via index and/or attribute matching:
 $("h1", 2, class: "heading")
 $("p", name: "description")
 $("ul.someClass li", 2)
Text value matching:
 $("h1", text: "All about Geb")
Chaining:
 $("div").find(".b")
 $("div").filter(".c").parents()
and many more built in capabilities.
GEB FEATURES
MORE …
 Geb has first class support for the Page Object pattern
for modelling the UI pages.
 Geb provides less code Ceremony.Geb has built-in DSL.
 Geb provides integration with testing frameworks such
as Spock, JUnit & TestNG.
 Geb is easy to integrate with build tools like Gradle and
Maven
GEB PAGE OBJECTS
BUILT-IN PAGE OBJECTS SUPPORT
 The page objects contains logic for page selectors and page operations.
 Groovy's DSL capabilities allows easily define the web pages in a
maintainable and extensible manner.
import geb.Page
class LoginPage extends Page {
static url = "http://myapp.com/login"
static at = { heading.text() == "Please Login" }
static content = {
heading { $("h1") }
loginForm { $("form.login") }
loginButton(to: WelcomePage) { $("input", type: "submit",
name: "login") }
}
}
class WelcomePage extends Page {
static at = { heading.text() == “Welcome to myApp" }
static content = {
heading { $("h1") }
}
}
Page
Objects
Geb DSL
GEB TEST CLASS
CLEAN TEST CODE
 The page objects contains logic for page selectors and page
operations.
 Test classes code is clean and reusable page objects code.
 Test classes contains
Mock data, assertions
and calls to page objects.
import geb.Browser
Browser.drive {
to LoginPage
assert at(LoginPage)
loginForm.with {
username = “myUser”
password = “myPassword”
}
loginButton.click()
assert at(WelcomePage)
}
GEB CODING SIMPLE
AJAX WAIT SIMPLE
 In Groovy Language = Less
Code Ceremony.
def element =
waitFor{$("p#dynamicContentI
d")}
// And then Assert code.
assert element.text() ==
"Added dynamically!"
 In Java Language = High Code
Ceremony.
WebDriverWait wait =
new WebDriverWait(driver,
10);
WebElement element =
wait.until(
ExpectedConditions.visibilit
yOfElementLocated(By.id("dyn
amicContentId")));
// And then Assert code…
assertEquals(element.getText
(), "Added dynamically!");
Geb + Groovy + Selenium Java + Selenium
GEB CONFIGURATION
SIMPLE TO CONFIGURE
 Geb allows Option to provide runtime arguments. Easy to run tests across multiple
browsers and multiple test environments without changing code.
–Dgeb.env=firefox (browser choice)
–Dbase.url=http://myapp.com/. (application url)
 Sample GebConfig.groovy file as below.
import org.openqa.selenium.*
waiting {
timeout = 10
}
// System property 'geb.env' is set to 'chrome' or 'ie' or 'firefox'
environments {
chrome { driver = { new ChromeDriver() } }
firefox { driver = { new FirefoxDriver()} }
ie { driver = { new InternetExplorerDriver() }
}
}
reportsDir = "target/geb-reports"
WHAT IS SPOCK?
SPECIFICATION LANGUAGE
 Spock is a testing framework written in Groovy
language.
 Good Test tool for Behavior-Driven Development (BDD).
 It’s highly expressive specification language.
 Runs with JUnit runner and compatible with all IDEs like
eclipse and IntellliJ.
SPOCK API
CODE BLOCKS AND IT’S PHASES
SPOCK BLOCKS
READABLE CODE BLOCKS
 Spock follows BDD’s Given-When-Then (Gherkin)
concept.
Given Step: put the system/browser in a known state/page
before the user.
When Step: describe the key action the user performs. UI
Operations like click.
Then Step: observe outcomes of test. Your assertions goes
here.
 Spock specification tests are more readable and
maintainable.
GEB WITH SPOCK
READABLE CODE
import geb.Page
import geb.spock.GebSpec
class LoginSpec extends GebSpec {
def "login to app"() {
given: "As an app user, access login page."
to LoginPage
when: "user enter valid login details"
loginForm.with {
username = "myUser"
password = "myPassword"
}
and: "performed login operation"
loginButton.click()
then: "user need to be successfully logged
in."
at WelcomePage
}
}
Spock Blocks
REFERENCE LINKS
 Selenium WebDriver
 Behavior-driven development
 Page Objects Pattern
 Book of Geb
 Spock Project
Thanks
Monika Gurram
KickStartPros.com

Contenu connexe

Tendances

Tendances (20)

ReactJS Tutorial For Beginners | ReactJS Redux Training For Beginners | React...
ReactJS Tutorial For Beginners | ReactJS Redux Training For Beginners | React...ReactJS Tutorial For Beginners | ReactJS Redux Training For Beginners | React...
ReactJS Tutorial For Beginners | ReactJS Redux Training For Beginners | React...
 
Introduction to Swagger
Introduction to SwaggerIntroduction to Swagger
Introduction to Swagger
 
Sql injection
Sql injectionSql injection
Sql injection
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
 
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...
 
Lazy vs. Eager Loading Strategies in JPA 2.1
Lazy vs. Eager Loading Strategies in JPA 2.1Lazy vs. Eager Loading Strategies in JPA 2.1
Lazy vs. Eager Loading Strategies in JPA 2.1
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
 
Angular 8
Angular 8 Angular 8
Angular 8
 
Selenium IDE LOCATORS
Selenium IDE LOCATORSSelenium IDE LOCATORS
Selenium IDE LOCATORS
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJS
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriver
 
Spring Framework Tutorial | Spring Tutorial For Beginners With Examples | Jav...
Spring Framework Tutorial | Spring Tutorial For Beginners With Examples | Jav...Spring Framework Tutorial | Spring Tutorial For Beginners With Examples | Jav...
Spring Framework Tutorial | Spring Tutorial For Beginners With Examples | Jav...
 
Java basic
Java basicJava basic
Java basic
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
 
3. Java Script
3. Java Script3. Java Script
3. Java Script
 
Looming Marvelous - Virtual Threads in Java Javaland.pdf
Looming Marvelous - Virtual Threads in Java Javaland.pdfLooming Marvelous - Virtual Threads in Java Javaland.pdf
Looming Marvelous - Virtual Threads in Java Javaland.pdf
 
OAuth2 and Spring Security
OAuth2 and Spring SecurityOAuth2 and Spring Security
OAuth2 and Spring Security
 
Selenium
SeleniumSelenium
Selenium
 
Swagger / Quick Start Guide
Swagger / Quick Start GuideSwagger / Quick Start Guide
Swagger / Quick Start Guide
 

En vedette

En vedette (20)

Taming Functional Web Testing with Spock and Geb
Taming Functional Web Testing with Spock and GebTaming Functional Web Testing with Spock and Geb
Taming Functional Web Testing with Spock and Geb
 
Smarter Testing With Spock
Smarter Testing With SpockSmarter Testing With Spock
Smarter Testing With Spock
 
Spock framework
Spock frameworkSpock framework
Spock framework
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEB
 
End-to-End Test Automation for Both Horizontal and Vertical Scale
End-to-End Test Automation for Both Horizontal and Vertical ScaleEnd-to-End Test Automation for Both Horizontal and Vertical Scale
End-to-End Test Automation for Both Horizontal and Vertical Scale
 
Smidig 2016 - Do you trust your test?
Smidig 2016 - Do you trust your test?Smidig 2016 - Do you trust your test?
Smidig 2016 - Do you trust your test?
 
Spock and Geb in Action
Spock and Geb in ActionSpock and Geb in Action
Spock and Geb in Action
 
Tests en Java con Groovy y Spock
Tests en Java con Groovy y SpockTests en Java con Groovy y Spock
Tests en Java con Groovy y Spock
 
Idiomatic spock
Idiomatic spockIdiomatic spock
Idiomatic spock
 
Acceptance testing with Geb
Acceptance testing with GebAcceptance testing with Geb
Acceptance testing with Geb
 
Geb for browser automation
Geb for browser automationGeb for browser automation
Geb for browser automation
 
Design Patterns from 10K feet
Design Patterns from 10K feetDesign Patterns from 10K feet
Design Patterns from 10K feet
 
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
 
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
 
Spock Framework
Spock FrameworkSpock Framework
Spock Framework
 
Functional testing your Grails app with GEB
Functional testing your Grails app with GEBFunctional testing your Grails app with GEB
Functional testing your Grails app with GEB
 
What makes Geb groovy?
What makes Geb groovy?What makes Geb groovy?
What makes Geb groovy?
 
Westrich spock-assets-gum
Westrich spock-assets-gumWestrich spock-assets-gum
Westrich spock-assets-gum
 
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
 

Similaire à Geb with spock

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
AgileNCR2013
 
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
supertoy2015
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
drewz lin
 

Similaire à Geb with spock (20)

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
 
Stanislaw potoczny kra_qa_21.01.20
Stanislaw potoczny kra_qa_21.01.20Stanislaw potoczny kra_qa_21.01.20
Stanislaw potoczny kra_qa_21.01.20
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finesse
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finesse
 
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
 
淺談 Geb 網站自動化測試(JCConf 2014)
淺談 Geb 網站自動化測試(JCConf 2014)淺談 Geb 網站自動化測試(JCConf 2014)
淺談 Geb 網站自動化測試(JCConf 2014)
 
Groovy and Grails intro
Groovy and Grails introGroovy and Grails intro
Groovy and Grails intro
 
Grails 101
Grails 101Grails 101
Grails 101
 
ASP.NET MVC Workshop for Women in Technology
ASP.NET MVC Workshop for Women in TechnologyASP.NET MVC Workshop for Women in Technology
ASP.NET MVC Workshop for Women in Technology
 
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
 
Play Framework on Google App Engine
Play Framework on Google App EnginePlay Framework on Google App Engine
Play Framework on Google App Engine
 
Geb+spock: let your functional tests live long and prosper
Geb+spock: let your functional tests live long and prosperGeb+spock: let your functional tests live long and prosper
Geb+spock: let your functional tests live long and prosper
 
Grunt Continuous Development of the Front End Tier
Grunt Continuous Development of the Front End TierGrunt Continuous Development of the Front End Tier
Grunt Continuous Development of the Front End Tier
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
 
Google App Engine With Java And Groovy
Google App Engine With Java And GroovyGoogle App Engine With Java And Groovy
Google App Engine With Java And Groovy
 
Griffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java TechnologyGriffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java Technology
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
 
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для брауз...
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для брауз...QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для брауз...
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для брауз...
 
OSGi enRoute Unveiled - P Kriens
OSGi enRoute Unveiled - P KriensOSGi enRoute Unveiled - P Kriens
OSGi enRoute Unveiled - P Kriens
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Dernier (20)

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 

Geb with spock

  • 1. GEB WITH SPOCK Browser Test automation and Specification Framework By Monika Gurram KickStartPros.com
  • 2. GEB FEATURES PRONOUNCED AS “JEB”  Geb is a browser automation framework written in Groovy Language.  Expressiveness and Dynamic nature of Groovy language makes Geb framework less Code Ceremony.  Geb uses power of Selenium WebDriver. Cross browser support.  Geb provides jQuery-like API for web content selection.
  • 3. GEB POWER GEB USES WEBDRIVER & GROOVY DSL  Selenium WebDriver 2.x cross browser support like IE, FF, Chrome, Opera & Headless browsers.  Groovy DSL to : option defines the page the browser will be sent to if the content is clicked. content : descripts the page web elements content. required : option controls whether or not the content returned by the definition has to exist or not. cache: option controls whether or not to evaluate each time the content is requested. Caching makes tests run fast. wait : wait for the content using default wait time. page: option allows the definition of a frame page.
  • 4. GEB NAVIGATOR API JQUERY-LIKE API  Navigator API is jQuery-like API for finding, filtering and interacting with DOM elements.  The $ Function for getting DOM elements: CSS3 Selectors:  $(«css selector», «index or range», «attribute/text matchers»)  $("div.some-class p:first[title='something']") Find via index and/or attribute matching:  $("h1", 2, class: "heading")  $("p", name: "description")  $("ul.someClass li", 2) Text value matching:  $("h1", text: "All about Geb") Chaining:  $("div").find(".b")  $("div").filter(".c").parents() and many more built in capabilities.
  • 5. GEB FEATURES MORE …  Geb has first class support for the Page Object pattern for modelling the UI pages.  Geb provides less code Ceremony.Geb has built-in DSL.  Geb provides integration with testing frameworks such as Spock, JUnit & TestNG.  Geb is easy to integrate with build tools like Gradle and Maven
  • 6. GEB PAGE OBJECTS BUILT-IN PAGE OBJECTS SUPPORT  The page objects contains logic for page selectors and page operations.  Groovy's DSL capabilities allows easily define the web pages in a maintainable and extensible manner. import geb.Page class LoginPage extends Page { static url = "http://myapp.com/login" static at = { heading.text() == "Please Login" } static content = { heading { $("h1") } loginForm { $("form.login") } loginButton(to: WelcomePage) { $("input", type: "submit", name: "login") } } } class WelcomePage extends Page { static at = { heading.text() == “Welcome to myApp" } static content = { heading { $("h1") } } } Page Objects Geb DSL
  • 7. GEB TEST CLASS CLEAN TEST CODE  The page objects contains logic for page selectors and page operations.  Test classes code is clean and reusable page objects code.  Test classes contains Mock data, assertions and calls to page objects. import geb.Browser Browser.drive { to LoginPage assert at(LoginPage) loginForm.with { username = “myUser” password = “myPassword” } loginButton.click() assert at(WelcomePage) }
  • 8. GEB CODING SIMPLE AJAX WAIT SIMPLE  In Groovy Language = Less Code Ceremony. def element = waitFor{$("p#dynamicContentI d")} // And then Assert code. assert element.text() == "Added dynamically!"  In Java Language = High Code Ceremony. WebDriverWait wait = new WebDriverWait(driver, 10); WebElement element = wait.until( ExpectedConditions.visibilit yOfElementLocated(By.id("dyn amicContentId"))); // And then Assert code… assertEquals(element.getText (), "Added dynamically!"); Geb + Groovy + Selenium Java + Selenium
  • 9. GEB CONFIGURATION SIMPLE TO CONFIGURE  Geb allows Option to provide runtime arguments. Easy to run tests across multiple browsers and multiple test environments without changing code. –Dgeb.env=firefox (browser choice) –Dbase.url=http://myapp.com/. (application url)  Sample GebConfig.groovy file as below. import org.openqa.selenium.* waiting { timeout = 10 } // System property 'geb.env' is set to 'chrome' or 'ie' or 'firefox' environments { chrome { driver = { new ChromeDriver() } } firefox { driver = { new FirefoxDriver()} } ie { driver = { new InternetExplorerDriver() } } } reportsDir = "target/geb-reports"
  • 10. WHAT IS SPOCK? SPECIFICATION LANGUAGE  Spock is a testing framework written in Groovy language.  Good Test tool for Behavior-Driven Development (BDD).  It’s highly expressive specification language.  Runs with JUnit runner and compatible with all IDEs like eclipse and IntellliJ.
  • 11. SPOCK API CODE BLOCKS AND IT’S PHASES
  • 12. SPOCK BLOCKS READABLE CODE BLOCKS  Spock follows BDD’s Given-When-Then (Gherkin) concept. Given Step: put the system/browser in a known state/page before the user. When Step: describe the key action the user performs. UI Operations like click. Then Step: observe outcomes of test. Your assertions goes here.  Spock specification tests are more readable and maintainable.
  • 13. GEB WITH SPOCK READABLE CODE import geb.Page import geb.spock.GebSpec class LoginSpec extends GebSpec { def "login to app"() { given: "As an app user, access login page." to LoginPage when: "user enter valid login details" loginForm.with { username = "myUser" password = "myPassword" } and: "performed login operation" loginButton.click() then: "user need to be successfully logged in." at WelcomePage } } Spock Blocks
  • 14. REFERENCE LINKS  Selenium WebDriver  Behavior-driven development  Page Objects Pattern  Book of Geb  Spock Project Thanks Monika Gurram KickStartPros.com