SlideShare a Scribd company logo
Ultimate Web Automation using WebDriver,
                    Groovy, JQuery and Domain Modelling
                                       It is just not all about Selenium 




Gaurav Bansal
Principal Consultant, Xebia

Phone: +91-989-984-9992
E-mail: gbansal@xebia.com
Challenges…
More Deliverables
  Fewer resources
  In less time
  With high quality
Finding Tool
Cost effective approaches
Integrated Framework
Web Automation Challenges..
Challenges                             Solution (Theory)

Multiple Browsers, Multiple Versions   Native to Web Browsers

                                       Powerful Element Querying
Complex Web Elements                   Capabilities


Coupling of Env. in scripts            Configuration Management

Duplicate/Unreadable/Non-
Maintainable Code                      Domain Modelling

Results - Required Statistics,
Screenshot etc                         Good Reporting


Boilerplate Code                       DSL


Test Representation Problem            BDD
Web Automation Solution..
Solution (Theory)           Solution (Practical)

Native to Web Browsers

Powerful Element Querying
Capabilities


Configuration Management               GEB
Domain Modelling            Geb’s Page Class
Good Reporting                     Geb
                             Geb’s Browser
DSL                               Class
BDD                                  Spock
What is Geb?
Geb is a browser automation solution.

It brings together the…
  Cross browser automation capabilities of
   WebDriver
  Elegance of jQuery content selection
  Expressiveness of the Groovy language
  Robustness of Page Object modelling
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
What is cool new in WebDriver?
PhantomJS Based
 Ghost Driver.

Implementation
 of WebDriver Wire
 Protocol.

Run your tests without
 launching a browser.
GhostDriver 1.0.0
   Navigation
   Page content extraction
   Arbitrary JS execution
   Window handling
   Frame handling
   Screen-shot generation
   Cookies
   Element Search, Localization & Manipulation
   Mouse interaction (even
    though doubleClick and rightClick seems to be a bit
    flaky)
   Keyboard interaction
Demo…
WebDriver API
Geb sits on top of WebDriver.

Geb never talks to the actual browser
 because that's what WebDriver does.
Geb's inspiration
“Navigator API” that is inspired by jQuery.

  // This is Geb code, not jQuery JavaScript…
    $("h1").previous().children();


API is not identical.
Dynamic JVM Lang.
Groovy is…
  Compiled, never interpreted
  Dynamic, optionally typed
  99% Java syntax compatible
  Concise & clear
  Great for DSLs
  A comfortable Java alternative for most
Geb & Groovy
Geb uses Groovy's dynamism to
 remove boilerplate.
 import geb.*
 Browser.drive {
       to GoogleHomePage
       at GoogleHomePage
        search.field.value("wikipedia")
        waitFor { at GoogleResultsPage }
        assert firstResultLink.text() == "Wikipedia"
        firstResultLink.click()
        waitFor { at WikipediaPage }
      }
Page Objects
 The key to not pulling your hair
out when dealing with web tests.
What are they?
 In a phrase: Domain Modelling.

 By modelling and creating abstractions, we can isolate implementation
  detail.

    $("input[name=username]").value("user")
    $("input[name=pwd]").value("password")
    $("input[type=submit]").click()

 Is far more fragile than this…

    void login(String username, String password) {
           $("input[name=username]").value(username)
           $("input[name=pwd]").value(password)
           $("input[type=submit]").click()
    }

    login("user", "password")
Browser has-a Page
Browser.drive {
     to GoogleHomePage
     at GoogleHomePage
     search.field.value("wikipedia")
     at GoogleResultsPage
     assert firstResultLink.text() == "Wikipedia"
     firstResultLink.click()
     waitFor { at WikipediaPage }
     }


 The to() and click() methods are changing the
  underlying page.
 You can refer to the current page's content and
  methods just by name.
Geb's Page Objects
Geb builds the Page Object pattern
 directly into the framework (though it is
 optional).
  import geb.*

  class GoogleHomePage extends Page {
        static url = "http://google.com/ncr"
        static at = { title == "Google" }
        static content = {
           search { module GoogleSearchModule }
        }
  }
Geb's Page Objects
Features the “Content DSL” for naming
 content in a dynamic and powerful way.

  import geb.*
  class GoogleResultsPage extends Page {
  static at = { waitFor { title.endsWith("Google Search") } }
  static content = {
          search { module GoogleSearchModule }
         results { $("li.g") }
          result { i -> results[i] }
         resultLink { i -> result(i).find("a.l", 0) }
           firstResultLink { resultLink(0) } } }
Modules
Modules are repeating
 and/or reappearing content.
import geb.*
class GoogleSearchModule extends Module {
   static content = {
      field { $("input", name: "q") }
      button(to: GoogleResultsPage) { $("input", value: buttonValue) }
   }
Testing
Geb's testing adapters
Geb for Testing
 Geb can be used with…
   Spock
   JUnit (3 & 4)
   TestNG
   EasyB
   Cucumber (Cuke4Duke)

 The majority of Geb users use Spock.
 Geb can dump HTML and screenshots for each
  “test” to help in debugging.
Navigator API
jQuery inspired content
  selection/navigation
Attribute/Text match
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.+/)
Relative Content
 $() returns a Navigator that allows you to find
  relative content.
   $("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")
Content DSL
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 build upon each
 other.
Content definitions are actually templates.
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 “required” option disables this check.
Dynamic Content
class DynamicPage extends Page {
    static content = {
       errorMsg(wait: true) { $("p.errorMsg") }
 }
}

 Geb will wait for some time for this content to
  appear.
 By default, it will look for it every 100ms for 5s
  before giving up. This is highly configurable.
 Same semantics as the waitFor {} method that
  can be used anywhere.
Expensive Content
class ExpensivePage extends Page {
   static content = {
     results(cache: true) { $("li.results") }
     result { results[it] }
 }
}


 By default, all content is transient.
 The cache option instructs Geb to hold on to the
  content, avoiding redundant lookups.
 Use carefully, can cause problems with dynamic
  pages.
Navigation
Getting around
The to() method
class GoogleHomePage extends Page {
   static url = "http://google.com/ncr"
}


Pages can define a url that defines the
 page location.
The to() method sends the browser there
 and sets that as the current page object.
Content based navigation
class FrontPage {
   static content = {
   aboutUsLink(to: AboutUsPage) { $("div#nav ul li a", text: iStartsWith("About Us")) }
    }
}

When this content is clicked, the
 underlying page will be changed
 implicitly.
     to FrontPage
     aboutUsLink.click()
     page instanceof AboutUsPage
At Checking
The “at checking” mechanism enables fail
 fast and less debugging.
class LoginPage extends Page {
   static at = { $("h1").text() == "Please log in" }
 }

browser.at LoginPage

Will throw an exception if every statement
 of the at check is not true.
Driver Management
Geb caches the WebDriver instance (per
 thread) and shares it across test cases.
Manages clearing cookies and is
 configurable.
Config. Management
Looks GebConfig.groovy file on classpath.
  driver = {
  new FirefoxDriver()
  }

  waiting {
  timeout = 2
  slow { timeout = 100 }
  }

  reportsDir = "geb-reports“

  environments {
  chrome { driver = "chrome" }
  }
Demo….Spock Example
Summary




JUnit4       Spock   Grails
  TestNG   EasyB
Thanks




            @gaurav_bansal
            gbansal@xebia.com /

More Related Content

What's hot

JavaScript and jQuery Basics
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery Basics
Kaloyan Kosev
 
JavaScript JQUERY AJAX
JavaScript JQUERY AJAXJavaScript JQUERY AJAX
JavaScript JQUERY AJAX
Makarand Bhatambarekar
 
Google
GoogleGoogle
Googlesoon
 
Authentication
AuthenticationAuthentication
Authenticationsoon
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQuery
Akshay Mathur
 
Difference between java script and jquery
Difference between java script and jqueryDifference between java script and jquery
Difference between java script and jquery
Umar Ali
 
Soa development using javascript
Soa development using javascriptSoa development using javascript
Soa development using javascriptDsixE Inc
 
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSONAn introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
Syed Moosa Kaleem
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JS
Akshay Mathur
 
Simplify AJAX using jQuery
Simplify AJAX using jQuerySimplify AJAX using jQuery
Simplify AJAX using jQuerySiva Arunachalam
 
Top 10 HTML5 features
Top 10 HTML5 featuresTop 10 HTML5 features
Top 10 HTML5 features
Gill Cleeren
 
Developing node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDBDeveloping node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDB
Rob Tweed
 
Suggest.js
Suggest.jsSuggest.js
Suggest.js
Mohd Saeed
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
Filip Janevski
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery Essentials
Mark Rackley
 
Using Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the WebUsing Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the Web
philogb
 
Service Oriented Architecture -Unit II - Modeling databases in xml
Service Oriented Architecture -Unit II - Modeling databases in xml Service Oriented Architecture -Unit II - Modeling databases in xml
Service Oriented Architecture -Unit II - Modeling databases in xml
Roselin Mary S
 
HTML5 & CSS3 refresher for mobile apps
HTML5 & CSS3 refresher for mobile appsHTML5 & CSS3 refresher for mobile apps
HTML5 & CSS3 refresher for mobile apps
Ivano Malavolta
 

What's hot (20)

JavaScript and jQuery Basics
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery Basics
 
JavaScript JQUERY AJAX
JavaScript JQUERY AJAXJavaScript JQUERY AJAX
JavaScript JQUERY AJAX
 
Google
GoogleGoogle
Google
 
Authentication
AuthenticationAuthentication
Authentication
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQuery
 
Difference between java script and jquery
Difference between java script and jqueryDifference between java script and jquery
Difference between java script and jquery
 
Soa development using javascript
Soa development using javascriptSoa development using javascript
Soa development using javascript
 
Knockout.js
Knockout.jsKnockout.js
Knockout.js
 
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSONAn introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JS
 
Simplify AJAX using jQuery
Simplify AJAX using jQuerySimplify AJAX using jQuery
Simplify AJAX using jQuery
 
Top 10 HTML5 features
Top 10 HTML5 featuresTop 10 HTML5 features
Top 10 HTML5 features
 
Developing node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDBDeveloping node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDB
 
Suggest.js
Suggest.jsSuggest.js
Suggest.js
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
 
JS basics
JS basicsJS basics
JS basics
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery Essentials
 
Using Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the WebUsing Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the Web
 
Service Oriented Architecture -Unit II - Modeling databases in xml
Service Oriented Architecture -Unit II - Modeling databases in xml Service Oriented Architecture -Unit II - Modeling databases in xml
Service Oriented Architecture -Unit II - Modeling databases in xml
 
HTML5 & CSS3 refresher for mobile apps
HTML5 & CSS3 refresher for mobile appsHTML5 & CSS3 refresher for mobile apps
HTML5 & CSS3 refresher for mobile apps
 

Viewers also liked

Happiness Workshop IV: The Importance of Relationships
Happiness Workshop IV: The Importance of RelationshipsHappiness Workshop IV: The Importance of Relationships
Happiness Workshop IV: The Importance of Relationships
michael_mascolo
 
Så funkar det (del 1) - word
Så funkar det (del 1) - wordSå funkar det (del 1) - word
Så funkar det (del 1) - word
Peter Antman
 
Visualize vascular (slides)
Visualize vascular  (slides)Visualize vascular  (slides)
Visualize vascular (slides)
Roger Saindon
 
Ch 6 Sec 1 "The Renaissance"
Ch 6 Sec 1 "The Renaissance"Ch 6 Sec 1 "The Renaissance"
Ch 6 Sec 1 "The Renaissance"
Attebery
 
Guion
GuionGuion
Examen final
Examen finalExamen final
Examen final
Jcabreraes
 
India Strategy V4 L
India Strategy V4 LIndia Strategy V4 L
India Strategy V4 L
ZENeSYS
 
Medidas de Tendencia Central
Medidas de Tendencia CentralMedidas de Tendencia Central
Medidas de Tendencia Centralerikamorenoc
 
Orientation program
Orientation programOrientation program
Orientation programdavpslr
 
la herramientas
la herramientasla herramientas
la herramientas
manuel davila aponte
 
Andrea Naranjo Brito diapositivas L.R.T.I
Andrea Naranjo Brito diapositivas L.R.T.IAndrea Naranjo Brito diapositivas L.R.T.I
Andrea Naranjo Brito diapositivas L.R.T.Iandreitanaranjo
 
La Jolla Guidebook
La Jolla GuidebookLa Jolla Guidebook
La Jolla Guidebook
Derek Searancke
 
Twitter: Now What? - Web 2.0 Conf. OCT, 2011, NYC
Twitter: Now What? -  Web 2.0 Conf. OCT, 2011, NYCTwitter: Now What? -  Web 2.0 Conf. OCT, 2011, NYC
Twitter: Now What? - Web 2.0 Conf. OCT, 2011, NYC
Victoria Harres
 
Inquinamento RIMAR - Trissino, 1979 - CTU tossicologico/analitica Prof. A. Li...
Inquinamento RIMAR - Trissino, 1979 - CTU tossicologico/analitica Prof. A. Li...Inquinamento RIMAR - Trissino, 1979 - CTU tossicologico/analitica Prof. A. Li...
Inquinamento RIMAR - Trissino, 1979 - CTU tossicologico/analitica Prof. A. Li...
Porfirina
 
Sinergi kebijakan MP3EI dengan Creative Destruction
Sinergi kebijakan MP3EI dengan Creative DestructionSinergi kebijakan MP3EI dengan Creative Destruction
Sinergi kebijakan MP3EI dengan Creative DestructionTri Cahyono
 
Agile Tour Chennai 2015: Continuous enterprise agility - Madhur Kathuria
Agile Tour Chennai 2015: Continuous enterprise agility - Madhur KathuriaAgile Tour Chennai 2015: Continuous enterprise agility - Madhur Kathuria
Agile Tour Chennai 2015: Continuous enterprise agility - Madhur Kathuria
India Scrum Enthusiasts Community
 
Pp no. 24 tahun 1976 tentang cuti pns
Pp no. 24 tahun 1976 tentang cuti pnsPp no. 24 tahun 1976 tentang cuti pns
Pp no. 24 tahun 1976 tentang cuti pns
Mng Tri Mulyono Prasetyo
 
designing branded enterprise experiences
designing branded enterprise experiencesdesigning branded enterprise experiences
designing branded enterprise experiences
Erik Roscam Abbing
 
Palos de golf, características y usos
Palos de golf, características y usosPalos de golf, características y usos
Palos de golf, características y usos
Club Martítimo Sotogrande
 

Viewers also liked (20)

Happiness Workshop IV: The Importance of Relationships
Happiness Workshop IV: The Importance of RelationshipsHappiness Workshop IV: The Importance of Relationships
Happiness Workshop IV: The Importance of Relationships
 
Så funkar det (del 1) - word
Så funkar det (del 1) - wordSå funkar det (del 1) - word
Så funkar det (del 1) - word
 
Visualize vascular (slides)
Visualize vascular  (slides)Visualize vascular  (slides)
Visualize vascular (slides)
 
Ch 6 Sec 1 "The Renaissance"
Ch 6 Sec 1 "The Renaissance"Ch 6 Sec 1 "The Renaissance"
Ch 6 Sec 1 "The Renaissance"
 
Guion
GuionGuion
Guion
 
Examen final
Examen finalExamen final
Examen final
 
India Strategy V4 L
India Strategy V4 LIndia Strategy V4 L
India Strategy V4 L
 
Medidas de Tendencia Central
Medidas de Tendencia CentralMedidas de Tendencia Central
Medidas de Tendencia Central
 
Orientation program
Orientation programOrientation program
Orientation program
 
la herramientas
la herramientasla herramientas
la herramientas
 
Andrea Naranjo Brito diapositivas L.R.T.I
Andrea Naranjo Brito diapositivas L.R.T.IAndrea Naranjo Brito diapositivas L.R.T.I
Andrea Naranjo Brito diapositivas L.R.T.I
 
La Jolla Guidebook
La Jolla GuidebookLa Jolla Guidebook
La Jolla Guidebook
 
Twitter: Now What? - Web 2.0 Conf. OCT, 2011, NYC
Twitter: Now What? -  Web 2.0 Conf. OCT, 2011, NYCTwitter: Now What? -  Web 2.0 Conf. OCT, 2011, NYC
Twitter: Now What? - Web 2.0 Conf. OCT, 2011, NYC
 
M&a apt en
M&a apt enM&a apt en
M&a apt en
 
Inquinamento RIMAR - Trissino, 1979 - CTU tossicologico/analitica Prof. A. Li...
Inquinamento RIMAR - Trissino, 1979 - CTU tossicologico/analitica Prof. A. Li...Inquinamento RIMAR - Trissino, 1979 - CTU tossicologico/analitica Prof. A. Li...
Inquinamento RIMAR - Trissino, 1979 - CTU tossicologico/analitica Prof. A. Li...
 
Sinergi kebijakan MP3EI dengan Creative Destruction
Sinergi kebijakan MP3EI dengan Creative DestructionSinergi kebijakan MP3EI dengan Creative Destruction
Sinergi kebijakan MP3EI dengan Creative Destruction
 
Agile Tour Chennai 2015: Continuous enterprise agility - Madhur Kathuria
Agile Tour Chennai 2015: Continuous enterprise agility - Madhur KathuriaAgile Tour Chennai 2015: Continuous enterprise agility - Madhur Kathuria
Agile Tour Chennai 2015: Continuous enterprise agility - Madhur Kathuria
 
Pp no. 24 tahun 1976 tentang cuti pns
Pp no. 24 tahun 1976 tentang cuti pnsPp no. 24 tahun 1976 tentang cuti pns
Pp no. 24 tahun 1976 tentang cuti pns
 
designing branded enterprise experiences
designing branded enterprise experiencesdesigning branded enterprise experiences
designing branded enterprise experiences
 
Palos de golf, características y usos
Palos de golf, características y usosPalos de golf, características y usos
Palos de golf, características y usos
 

Similar to Agile NCR 2013 - Gaurav Bansal- web_automation

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
C4Media
 
Geb with spock
Geb with spockGeb with spock
Geb with spock
Monika Gurram
 
Geb presentation
Geb presentationGeb presentation
Geb presentation
Ivar Østhus
 
[@IndeedEng] Building Indeed Resume Search
[@IndeedEng] Building Indeed Resume Search[@IndeedEng] Building Indeed Resume Search
[@IndeedEng] Building Indeed Resume Search
indeedeng
 
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
kraqa
 
BDD, ATDD, Page Objects: The Road to Sustainable Web Testing
BDD, ATDD, Page Objects: The Road to Sustainable Web TestingBDD, ATDD, Page Objects: The Road to Sustainable Web Testing
BDD, ATDD, Page Objects: The Road to Sustainable Web Testing
John Ferguson Smart Limited
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instruments
Artem Nagornyi
 
End-to-end testing with geb
End-to-end testing with gebEnd-to-end testing with geb
End-to-end testing with geb
Jesús L. Domínguez Muriel
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
Ioan Eugen Stan
 
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 testingdrewz lin
 
Kiss PageObjects [01-2017]
Kiss PageObjects [01-2017]Kiss PageObjects [01-2017]
Kiss PageObjects [01-2017]
Iakiv Kramarenko
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
toddbr
 
Everything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the WebEverything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the Web
James Rakich
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
Andrew Rota
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e bigAndy Peterson
 
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
Leticia Rss
 
Testing in AngularJS
Testing in AngularJSTesting in AngularJS
Testing in AngularJS
Peter Drinnan
 
OSGi and Spring Data for simple (Web) Application Development
OSGi and Spring Data  for simple (Web) Application DevelopmentOSGi and Spring Data  for simple (Web) Application Development
OSGi and Spring Data for simple (Web) Application Development
Christian Baranowski
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NET
Ben Hall
 
Acceptance testing with Geb
Acceptance testing with GebAcceptance testing with Geb
Acceptance testing with Geb
Richard Paul
 

Similar to Agile NCR 2013 - Gaurav Bansal- web_automation (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
 
Geb with spock
Geb with spockGeb with spock
Geb with spock
 
Geb presentation
Geb presentationGeb presentation
Geb presentation
 
[@IndeedEng] Building Indeed Resume Search
[@IndeedEng] Building Indeed Resume Search[@IndeedEng] Building Indeed Resume Search
[@IndeedEng] Building Indeed Resume Search
 
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
 
BDD, ATDD, Page Objects: The Road to Sustainable Web Testing
BDD, ATDD, Page Objects: The Road to Sustainable Web TestingBDD, ATDD, Page Objects: The Road to Sustainable Web Testing
BDD, ATDD, Page Objects: The Road to Sustainable Web Testing
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instruments
 
End-to-end testing with geb
End-to-end testing with gebEnd-to-end testing with geb
End-to-end testing with geb
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
 
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
 
Kiss PageObjects [01-2017]
Kiss PageObjects [01-2017]Kiss PageObjects [01-2017]
Kiss PageObjects [01-2017]
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
Everything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the WebEverything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the Web
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
 
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
 
Testing in AngularJS
Testing in AngularJSTesting in AngularJS
Testing in AngularJS
 
OSGi and Spring Data for simple (Web) Application Development
OSGi and Spring Data  for simple (Web) Application DevelopmentOSGi and Spring Data  for simple (Web) Application Development
OSGi and Spring Data for simple (Web) Application Development
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NET
 
Acceptance testing with Geb
Acceptance testing with GebAcceptance testing with Geb
Acceptance testing with Geb
 

More from AgileNCR2013

Agile NCR 2013- Anirudh Bhatnagar - Hadoop unit testing agile ncr
Agile NCR 2013- Anirudh Bhatnagar - Hadoop unit testing agile ncr Agile NCR 2013- Anirudh Bhatnagar - Hadoop unit testing agile ncr
Agile NCR 2013- Anirudh Bhatnagar - Hadoop unit testing agile ncr AgileNCR2013
 
Agile NCR 2013-Tushar Soimya - Executives role in agile
Agile NCR 2013-Tushar Soimya - Executives role in agileAgile NCR 2013-Tushar Soimya - Executives role in agile
Agile NCR 2013-Tushar Soimya - Executives role in agileAgileNCR2013
 
Agile NCR 2013 - Pooja Jagtap - presentation on thinking beyond strategic hr..
Agile NCR 2013 - Pooja Jagtap - presentation on thinking beyond strategic hr..Agile NCR 2013 - Pooja Jagtap - presentation on thinking beyond strategic hr..
Agile NCR 2013 - Pooja Jagtap - presentation on thinking beyond strategic hr..AgileNCR2013
 
Agile NCR 2013- Shekhar Gulati - Open shift platform-for-rapid-and-agile-deve...
Agile NCR 2013- Shekhar Gulati - Open shift platform-for-rapid-and-agile-deve...Agile NCR 2013- Shekhar Gulati - Open shift platform-for-rapid-and-agile-deve...
Agile NCR 2013- Shekhar Gulati - Open shift platform-for-rapid-and-agile-deve...AgileNCR2013
 
Agile NCR 2013- Jainendra Kumar - agilemethodology-pitneybowe-jai1
Agile NCR 2013-  Jainendra Kumar - agilemethodology-pitneybowe-jai1Agile NCR 2013-  Jainendra Kumar - agilemethodology-pitneybowe-jai1
Agile NCR 2013- Jainendra Kumar - agilemethodology-pitneybowe-jai1AgileNCR2013
 
Agile NCR 2013 - Archana Joshi - maintaining agile equilibrium v4
Agile NCR 2013 - Archana Joshi -  maintaining agile equilibrium v4Agile NCR 2013 - Archana Joshi -  maintaining agile equilibrium v4
Agile NCR 2013 - Archana Joshi - maintaining agile equilibrium v4AgileNCR2013
 
Agile NCR 2013 - Puneet sachdev - Pragmatic Agile Adoption
Agile NCR 2013 - Puneet sachdev - Pragmatic Agile AdoptionAgile NCR 2013 - Puneet sachdev - Pragmatic Agile Adoption
Agile NCR 2013 - Puneet sachdev - Pragmatic Agile AdoptionAgileNCR2013
 
Agile NCR 2013 - Milind Agnihotri - Agile &amp; the imperatives of effective ...
Agile NCR 2013 - Milind Agnihotri - Agile &amp; the imperatives of effective ...Agile NCR 2013 - Milind Agnihotri - Agile &amp; the imperatives of effective ...
Agile NCR 2013 - Milind Agnihotri - Agile &amp; the imperatives of effective ...AgileNCR2013
 
Agile NCR 2013 - Serge Beaumont - welcome to agile ncr 2014
Agile NCR 2013 - Serge Beaumont -  welcome to agile ncr 2014 Agile NCR 2013 - Serge Beaumont -  welcome to agile ncr 2014
Agile NCR 2013 - Serge Beaumont - welcome to agile ncr 2014 AgileNCR2013
 
Agile NCR 2013 - Seema Verma - energizing hr for agile excellence-competency...
Agile NCR 2013 - Seema Verma -  energizing hr for agile excellence-competency...Agile NCR 2013 - Seema Verma -  energizing hr for agile excellence-competency...
Agile NCR 2013 - Seema Verma - energizing hr for agile excellence-competency...AgileNCR2013
 

More from AgileNCR2013 (10)

Agile NCR 2013- Anirudh Bhatnagar - Hadoop unit testing agile ncr
Agile NCR 2013- Anirudh Bhatnagar - Hadoop unit testing agile ncr Agile NCR 2013- Anirudh Bhatnagar - Hadoop unit testing agile ncr
Agile NCR 2013- Anirudh Bhatnagar - Hadoop unit testing agile ncr
 
Agile NCR 2013-Tushar Soimya - Executives role in agile
Agile NCR 2013-Tushar Soimya - Executives role in agileAgile NCR 2013-Tushar Soimya - Executives role in agile
Agile NCR 2013-Tushar Soimya - Executives role in agile
 
Agile NCR 2013 - Pooja Jagtap - presentation on thinking beyond strategic hr..
Agile NCR 2013 - Pooja Jagtap - presentation on thinking beyond strategic hr..Agile NCR 2013 - Pooja Jagtap - presentation on thinking beyond strategic hr..
Agile NCR 2013 - Pooja Jagtap - presentation on thinking beyond strategic hr..
 
Agile NCR 2013- Shekhar Gulati - Open shift platform-for-rapid-and-agile-deve...
Agile NCR 2013- Shekhar Gulati - Open shift platform-for-rapid-and-agile-deve...Agile NCR 2013- Shekhar Gulati - Open shift platform-for-rapid-and-agile-deve...
Agile NCR 2013- Shekhar Gulati - Open shift platform-for-rapid-and-agile-deve...
 
Agile NCR 2013- Jainendra Kumar - agilemethodology-pitneybowe-jai1
Agile NCR 2013-  Jainendra Kumar - agilemethodology-pitneybowe-jai1Agile NCR 2013-  Jainendra Kumar - agilemethodology-pitneybowe-jai1
Agile NCR 2013- Jainendra Kumar - agilemethodology-pitneybowe-jai1
 
Agile NCR 2013 - Archana Joshi - maintaining agile equilibrium v4
Agile NCR 2013 - Archana Joshi -  maintaining agile equilibrium v4Agile NCR 2013 - Archana Joshi -  maintaining agile equilibrium v4
Agile NCR 2013 - Archana Joshi - maintaining agile equilibrium v4
 
Agile NCR 2013 - Puneet sachdev - Pragmatic Agile Adoption
Agile NCR 2013 - Puneet sachdev - Pragmatic Agile AdoptionAgile NCR 2013 - Puneet sachdev - Pragmatic Agile Adoption
Agile NCR 2013 - Puneet sachdev - Pragmatic Agile Adoption
 
Agile NCR 2013 - Milind Agnihotri - Agile &amp; the imperatives of effective ...
Agile NCR 2013 - Milind Agnihotri - Agile &amp; the imperatives of effective ...Agile NCR 2013 - Milind Agnihotri - Agile &amp; the imperatives of effective ...
Agile NCR 2013 - Milind Agnihotri - Agile &amp; the imperatives of effective ...
 
Agile NCR 2013 - Serge Beaumont - welcome to agile ncr 2014
Agile NCR 2013 - Serge Beaumont -  welcome to agile ncr 2014 Agile NCR 2013 - Serge Beaumont -  welcome to agile ncr 2014
Agile NCR 2013 - Serge Beaumont - welcome to agile ncr 2014
 
Agile NCR 2013 - Seema Verma - energizing hr for agile excellence-competency...
Agile NCR 2013 - Seema Verma -  energizing hr for agile excellence-competency...Agile NCR 2013 - Seema Verma -  energizing hr for agile excellence-competency...
Agile NCR 2013 - Seema Verma - energizing hr for agile excellence-competency...
 

Recently uploaded

Cree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBdCree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBd
creerey
 
ModelingMarketingStrategiesMKS.CollumbiaUniversitypdf
ModelingMarketingStrategiesMKS.CollumbiaUniversitypdfModelingMarketingStrategiesMKS.CollumbiaUniversitypdf
ModelingMarketingStrategiesMKS.CollumbiaUniversitypdf
fisherameliaisabella
 
Maksym Vyshnivetskyi: PMO Quality Management (UA)
Maksym Vyshnivetskyi: PMO Quality Management (UA)Maksym Vyshnivetskyi: PMO Quality Management (UA)
Maksym Vyshnivetskyi: PMO Quality Management (UA)
Lviv Startup Club
 
Introduction to Amazon company 111111111111
Introduction to Amazon company 111111111111Introduction to Amazon company 111111111111
Introduction to Amazon company 111111111111
zoyaansari11365
 
falcon-invoice-discounting-a-premier-platform-for-investors-in-india
falcon-invoice-discounting-a-premier-platform-for-investors-in-indiafalcon-invoice-discounting-a-premier-platform-for-investors-in-india
falcon-invoice-discounting-a-premier-platform-for-investors-in-india
Falcon Invoice Discounting
 
RMD24 | Debunking the non-endemic revenue myth Marvin Vacquier Droop | First ...
RMD24 | Debunking the non-endemic revenue myth Marvin Vacquier Droop | First ...RMD24 | Debunking the non-endemic revenue myth Marvin Vacquier Droop | First ...
RMD24 | Debunking the non-endemic revenue myth Marvin Vacquier Droop | First ...
BBPMedia1
 
CADAVER AS OUR FIRST TEACHER anatomt in your.pptx
CADAVER AS OUR FIRST TEACHER anatomt in your.pptxCADAVER AS OUR FIRST TEACHER anatomt in your.pptx
CADAVER AS OUR FIRST TEACHER anatomt in your.pptx
fakeloginn69
 
Premium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern BusinessesPremium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern Businesses
SynapseIndia
 
Discover the innovative and creative projects that highlight my journey throu...
Discover the innovative and creative projects that highlight my journey throu...Discover the innovative and creative projects that highlight my journey throu...
Discover the innovative and creative projects that highlight my journey throu...
dylandmeas
 
5 Things You Need To Know Before Hiring a Videographer
5 Things You Need To Know Before Hiring a Videographer5 Things You Need To Know Before Hiring a Videographer
5 Things You Need To Know Before Hiring a Videographer
ofm712785
 
The Parable of the Pipeline a book every new businessman or business student ...
The Parable of the Pipeline a book every new businessman or business student ...The Parable of the Pipeline a book every new businessman or business student ...
The Parable of the Pipeline a book every new businessman or business student ...
awaisafdar
 
Affordable Stationery Printing Services in Jaipur | Navpack n Print
Affordable Stationery Printing Services in Jaipur | Navpack n PrintAffordable Stationery Printing Services in Jaipur | Navpack n Print
Affordable Stationery Printing Services in Jaipur | Navpack n Print
Navpack & Print
 
Mastering B2B Payments Webinar from BlueSnap
Mastering B2B Payments Webinar from BlueSnapMastering B2B Payments Webinar from BlueSnap
Mastering B2B Payments Webinar from BlueSnap
Norma Mushkat Gaffin
 
Kseniya Leshchenko: Shared development support service model as the way to ma...
Kseniya Leshchenko: Shared development support service model as the way to ma...Kseniya Leshchenko: Shared development support service model as the way to ma...
Kseniya Leshchenko: Shared development support service model as the way to ma...
Lviv Startup Club
 
20240425_ TJ Communications Credentials_compressed.pdf
20240425_ TJ Communications Credentials_compressed.pdf20240425_ TJ Communications Credentials_compressed.pdf
20240425_ TJ Communications Credentials_compressed.pdf
tjcomstrang
 
Putting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptxPutting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptx
Cynthia Clay
 
Authentically Social Presented by Corey Perlman
Authentically Social Presented by Corey PerlmanAuthentically Social Presented by Corey Perlman
Authentically Social Presented by Corey Perlman
Corey Perlman, Social Media Speaker and Consultant
 
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.docBài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc
daothibichhang1
 
Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024
FelixPerez547899
 
Creative Web Design Company in Singapore
Creative Web Design Company in SingaporeCreative Web Design Company in Singapore
Creative Web Design Company in Singapore
techboxsqauremedia
 

Recently uploaded (20)

Cree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBdCree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBd
 
ModelingMarketingStrategiesMKS.CollumbiaUniversitypdf
ModelingMarketingStrategiesMKS.CollumbiaUniversitypdfModelingMarketingStrategiesMKS.CollumbiaUniversitypdf
ModelingMarketingStrategiesMKS.CollumbiaUniversitypdf
 
Maksym Vyshnivetskyi: PMO Quality Management (UA)
Maksym Vyshnivetskyi: PMO Quality Management (UA)Maksym Vyshnivetskyi: PMO Quality Management (UA)
Maksym Vyshnivetskyi: PMO Quality Management (UA)
 
Introduction to Amazon company 111111111111
Introduction to Amazon company 111111111111Introduction to Amazon company 111111111111
Introduction to Amazon company 111111111111
 
falcon-invoice-discounting-a-premier-platform-for-investors-in-india
falcon-invoice-discounting-a-premier-platform-for-investors-in-indiafalcon-invoice-discounting-a-premier-platform-for-investors-in-india
falcon-invoice-discounting-a-premier-platform-for-investors-in-india
 
RMD24 | Debunking the non-endemic revenue myth Marvin Vacquier Droop | First ...
RMD24 | Debunking the non-endemic revenue myth Marvin Vacquier Droop | First ...RMD24 | Debunking the non-endemic revenue myth Marvin Vacquier Droop | First ...
RMD24 | Debunking the non-endemic revenue myth Marvin Vacquier Droop | First ...
 
CADAVER AS OUR FIRST TEACHER anatomt in your.pptx
CADAVER AS OUR FIRST TEACHER anatomt in your.pptxCADAVER AS OUR FIRST TEACHER anatomt in your.pptx
CADAVER AS OUR FIRST TEACHER anatomt in your.pptx
 
Premium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern BusinessesPremium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern Businesses
 
Discover the innovative and creative projects that highlight my journey throu...
Discover the innovative and creative projects that highlight my journey throu...Discover the innovative and creative projects that highlight my journey throu...
Discover the innovative and creative projects that highlight my journey throu...
 
5 Things You Need To Know Before Hiring a Videographer
5 Things You Need To Know Before Hiring a Videographer5 Things You Need To Know Before Hiring a Videographer
5 Things You Need To Know Before Hiring a Videographer
 
The Parable of the Pipeline a book every new businessman or business student ...
The Parable of the Pipeline a book every new businessman or business student ...The Parable of the Pipeline a book every new businessman or business student ...
The Parable of the Pipeline a book every new businessman or business student ...
 
Affordable Stationery Printing Services in Jaipur | Navpack n Print
Affordable Stationery Printing Services in Jaipur | Navpack n PrintAffordable Stationery Printing Services in Jaipur | Navpack n Print
Affordable Stationery Printing Services in Jaipur | Navpack n Print
 
Mastering B2B Payments Webinar from BlueSnap
Mastering B2B Payments Webinar from BlueSnapMastering B2B Payments Webinar from BlueSnap
Mastering B2B Payments Webinar from BlueSnap
 
Kseniya Leshchenko: Shared development support service model as the way to ma...
Kseniya Leshchenko: Shared development support service model as the way to ma...Kseniya Leshchenko: Shared development support service model as the way to ma...
Kseniya Leshchenko: Shared development support service model as the way to ma...
 
20240425_ TJ Communications Credentials_compressed.pdf
20240425_ TJ Communications Credentials_compressed.pdf20240425_ TJ Communications Credentials_compressed.pdf
20240425_ TJ Communications Credentials_compressed.pdf
 
Putting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptxPutting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptx
 
Authentically Social Presented by Corey Perlman
Authentically Social Presented by Corey PerlmanAuthentically Social Presented by Corey Perlman
Authentically Social Presented by Corey Perlman
 
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.docBài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc
 
Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024
 
Creative Web Design Company in Singapore
Creative Web Design Company in SingaporeCreative Web Design Company in Singapore
Creative Web Design Company in Singapore
 

Agile NCR 2013 - Gaurav Bansal- web_automation

  • 1. Ultimate Web Automation using WebDriver, Groovy, JQuery and Domain Modelling It is just not all about Selenium  Gaurav Bansal Principal Consultant, Xebia Phone: +91-989-984-9992 E-mail: gbansal@xebia.com
  • 2. Challenges… More Deliverables Fewer resources In less time With high quality Finding Tool Cost effective approaches Integrated Framework
  • 3. Web Automation Challenges.. Challenges Solution (Theory) Multiple Browsers, Multiple Versions Native to Web Browsers Powerful Element Querying Complex Web Elements Capabilities Coupling of Env. in scripts Configuration Management Duplicate/Unreadable/Non- Maintainable Code Domain Modelling Results - Required Statistics, Screenshot etc Good Reporting Boilerplate Code DSL Test Representation Problem BDD
  • 4. Web Automation Solution.. Solution (Theory) Solution (Practical) Native to Web Browsers Powerful Element Querying Capabilities Configuration Management GEB Domain Modelling Geb’s Page Class Good Reporting Geb Geb’s Browser DSL Class BDD Spock
  • 5. What is Geb? Geb is a browser automation solution. It brings together the… Cross browser automation capabilities of WebDriver Elegance of jQuery content selection Expressiveness of the Groovy language Robustness of Page Object modelling
  • 6. 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
  • 8. What is cool new in WebDriver? PhantomJS Based Ghost Driver. Implementation of WebDriver Wire Protocol. Run your tests without launching a browser.
  • 9. GhostDriver 1.0.0  Navigation  Page content extraction  Arbitrary JS execution  Window handling  Frame handling  Screen-shot generation  Cookies  Element Search, Localization & Manipulation  Mouse interaction (even though doubleClick and rightClick seems to be a bit flaky)  Keyboard interaction
  • 11. WebDriver API Geb sits on top of WebDriver. Geb never talks to the actual browser because that's what WebDriver does.
  • 12. Geb's inspiration “Navigator API” that is inspired by jQuery. // This is Geb code, not jQuery JavaScript… $("h1").previous().children(); API is not identical.
  • 13. Dynamic JVM Lang. Groovy is… Compiled, never interpreted Dynamic, optionally typed 99% Java syntax compatible Concise & clear Great for DSLs A comfortable Java alternative for most
  • 14. Geb & Groovy Geb uses Groovy's dynamism to remove boilerplate. import geb.* Browser.drive { to GoogleHomePage at GoogleHomePage search.field.value("wikipedia") waitFor { at GoogleResultsPage } assert firstResultLink.text() == "Wikipedia" firstResultLink.click() waitFor { at WikipediaPage } }
  • 15. Page Objects The key to not pulling your hair out when dealing with web tests.
  • 16. What are they?  In a phrase: Domain Modelling.  By modelling and creating abstractions, we can isolate implementation detail. $("input[name=username]").value("user") $("input[name=pwd]").value("password") $("input[type=submit]").click()  Is far more fragile than this… void login(String username, String password) { $("input[name=username]").value(username) $("input[name=pwd]").value(password) $("input[type=submit]").click() } login("user", "password")
  • 17. Browser has-a Page Browser.drive { to GoogleHomePage at GoogleHomePage search.field.value("wikipedia") at GoogleResultsPage assert firstResultLink.text() == "Wikipedia" firstResultLink.click() waitFor { at WikipediaPage } }  The to() and click() methods are changing the underlying page.  You can refer to the current page's content and methods just by name.
  • 18. Geb's Page Objects Geb builds the Page Object pattern directly into the framework (though it is optional). import geb.* class GoogleHomePage extends Page { static url = "http://google.com/ncr" static at = { title == "Google" } static content = { search { module GoogleSearchModule } } }
  • 19. Geb's Page Objects Features the “Content DSL” for naming content in a dynamic and powerful way. import geb.* class GoogleResultsPage extends Page { static at = { waitFor { title.endsWith("Google Search") } } static content = { search { module GoogleSearchModule } results { $("li.g") } result { i -> results[i] } resultLink { i -> result(i).find("a.l", 0) } firstResultLink { resultLink(0) } } }
  • 20. Modules Modules are repeating and/or reappearing content. import geb.* class GoogleSearchModule extends Module { static content = { field { $("input", name: "q") } button(to: GoogleResultsPage) { $("input", value: buttonValue) } }
  • 22. Geb for Testing  Geb can be used with…  Spock  JUnit (3 & 4)  TestNG  EasyB  Cucumber (Cuke4Duke)  The majority of Geb users use Spock.  Geb can dump HTML and screenshots for each “test” to help in debugging.
  • 23. Navigator API jQuery inspired content selection/navigation
  • 24. Attribute/Text match 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.+/)
  • 25. Relative Content  $() returns a Navigator that allows you to find relative content. $("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")
  • 27. 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 build upon each other. Content definitions are actually templates.
  • 28. 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 “required” option disables this check.
  • 29. Dynamic Content class DynamicPage extends Page { static content = { errorMsg(wait: true) { $("p.errorMsg") } } }  Geb will wait for some time for this content to appear.  By default, it will look for it every 100ms for 5s before giving up. This is highly configurable.  Same semantics as the waitFor {} method that can be used anywhere.
  • 30. Expensive Content class ExpensivePage extends Page { static content = { results(cache: true) { $("li.results") } result { results[it] } } }  By default, all content is transient.  The cache option instructs Geb to hold on to the content, avoiding redundant lookups.  Use carefully, can cause problems with dynamic pages.
  • 32. The to() method class GoogleHomePage extends Page { static url = "http://google.com/ncr" } Pages can define a url that defines the page location. The to() method sends the browser there and sets that as the current page object.
  • 33. Content based navigation class FrontPage { static content = { aboutUsLink(to: AboutUsPage) { $("div#nav ul li a", text: iStartsWith("About Us")) } } } When this content is clicked, the underlying page will be changed implicitly. to FrontPage aboutUsLink.click() page instanceof AboutUsPage
  • 34. At Checking The “at checking” mechanism enables fail fast and less debugging. class LoginPage extends Page { static at = { $("h1").text() == "Please log in" } } browser.at LoginPage Will throw an exception if every statement of the at check is not true.
  • 35. Driver Management Geb caches the WebDriver instance (per thread) and shares it across test cases. Manages clearing cookies and is configurable.
  • 36. Config. Management Looks GebConfig.groovy file on classpath. driver = { new FirefoxDriver() } waiting { timeout = 2 slow { timeout = 100 } } reportsDir = "geb-reports“ environments { chrome { driver = "chrome" } }
  • 38. Summary JUnit4 Spock Grails TestNG EasyB
  • 39. Thanks  @gaurav_bansal  gbansal@xebia.com /