SlideShare une entreprise Scribd logo
1  sur  39
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 /

Contenu connexe

Tendances

JavaScript and jQuery Basics
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery BasicsKaloyan Kosev
 
Google
GoogleGoogle
Googlesoon
 
Authentication
AuthenticationAuthentication
Authenticationsoon
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQueryAkshay Mathur
 
Difference between java script and jquery
Difference between java script and jqueryDifference between java script and jquery
Difference between java script and jqueryUmar 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 JSONSyed Moosa Kaleem
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JSAkshay 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 featuresGill 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 SimpleDBRob Tweed
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery EssentialsMark 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 Webphilogb
 
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 appsIvano Malavolta
 

Tendances (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
 

En vedette

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 Relationshipsmichael_mascolo
 
Så funkar det (del 1) - word
Så funkar det (del 1) - wordSå funkar det (del 1) - word
Så funkar det (del 1) - wordPeter 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
 
India Strategy V4 L
India Strategy V4 LIndia Strategy V4 L
India Strategy V4 LZENeSYS
 
Medidas de Tendencia Central
Medidas de Tendencia CentralMedidas de Tendencia Central
Medidas de Tendencia Centralerikamorenoc
 
Orientation program
Orientation programOrientation program
Orientation programdavpslr
 
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
 
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, NYCVictoria 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 KathuriaIndia Scrum Enthusiasts Community
 
designing branded enterprise experiences
designing branded enterprise experiencesdesigning branded enterprise experiences
designing branded enterprise experiencesErik Roscam Abbing
 

En vedette (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
 

Similaire à 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 GebC4Media
 
[@IndeedEng] Building Indeed Resume Search
[@IndeedEng] Building Indeed Resume Search[@IndeedEng] Building Indeed Resume Search
[@IndeedEng] Building Indeed Resume Searchindeedeng
 
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.20kraqa
 
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 TestingJohn Ferguson Smart Limited
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instrumentsArtem Nagornyi
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest servicesIoan 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 citizenerytoddbr
 
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 WebJames 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 ApplicationAndrew 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 pageobjectsLeticia Rss
 
Testing in AngularJS
Testing in AngularJSTesting in AngularJS
Testing in AngularJSPeter 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 DevelopmentChristian Baranowski
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETBen Hall
 
Acceptance testing with Geb
Acceptance testing with GebAcceptance testing with Geb
Acceptance testing with GebRichard Paul
 

Similaire à 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
 

Plus de 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
 

Plus de 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...
 

Dernier

trending-flavors-and-ingredients-in-salty-snacks-us-2024_Redacted-V2.pdf
trending-flavors-and-ingredients-in-salty-snacks-us-2024_Redacted-V2.pdftrending-flavors-and-ingredients-in-salty-snacks-us-2024_Redacted-V2.pdf
trending-flavors-and-ingredients-in-salty-snacks-us-2024_Redacted-V2.pdfMintel Group
 
WSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfWSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfJamesConcepcion7
 
business environment micro environment macro environment.pptx
business environment micro environment macro environment.pptxbusiness environment micro environment macro environment.pptx
business environment micro environment macro environment.pptxShruti Mittal
 
Planetary and Vedic Yagyas Bring Positive Impacts in Life
Planetary and Vedic Yagyas Bring Positive Impacts in LifePlanetary and Vedic Yagyas Bring Positive Impacts in Life
Planetary and Vedic Yagyas Bring Positive Impacts in LifeBhavana Pujan Kendra
 
Onemonitar Android Spy App Features: Explore Advanced Monitoring Capabilities
Onemonitar Android Spy App Features: Explore Advanced Monitoring CapabilitiesOnemonitar Android Spy App Features: Explore Advanced Monitoring Capabilities
Onemonitar Android Spy App Features: Explore Advanced Monitoring CapabilitiesOne Monitar
 
Healthcare Feb. & Mar. Healthcare Newsletter
Healthcare Feb. & Mar. Healthcare NewsletterHealthcare Feb. & Mar. Healthcare Newsletter
Healthcare Feb. & Mar. Healthcare NewsletterJamesConcepcion7
 
Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...
Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...
Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...Associazione Digital Days
 
Welding Electrode Making Machine By Deccan Dynamics
Welding Electrode Making Machine By Deccan DynamicsWelding Electrode Making Machine By Deccan Dynamics
Welding Electrode Making Machine By Deccan DynamicsIndiaMART InterMESH Limited
 
Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03DallasHaselhorst
 
Jewish Resources in the Family Resource Centre
Jewish Resources in the Family Resource CentreJewish Resources in the Family Resource Centre
Jewish Resources in the Family Resource CentreNZSG
 
Technical Leaders - Working with the Management Team
Technical Leaders - Working with the Management TeamTechnical Leaders - Working with the Management Team
Technical Leaders - Working with the Management TeamArik Fletcher
 
Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Anamaria Contreras
 
1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdfShaun Heinrichs
 
Darshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdfDarshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdfShashank Mehta
 
Go for Rakhi Bazaar and Pick the Latest Bhaiya Bhabhi Rakhi.pptx
Go for Rakhi Bazaar and Pick the Latest Bhaiya Bhabhi Rakhi.pptxGo for Rakhi Bazaar and Pick the Latest Bhaiya Bhabhi Rakhi.pptx
Go for Rakhi Bazaar and Pick the Latest Bhaiya Bhabhi Rakhi.pptxRakhi Bazaar
 
1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdfShaun Heinrichs
 
WSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdfWSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdfJamesConcepcion7
 
How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...
How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...
How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...SOFTTECHHUB
 
Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...
Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...
Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...ssuserf63bd7
 

Dernier (20)

trending-flavors-and-ingredients-in-salty-snacks-us-2024_Redacted-V2.pdf
trending-flavors-and-ingredients-in-salty-snacks-us-2024_Redacted-V2.pdftrending-flavors-and-ingredients-in-salty-snacks-us-2024_Redacted-V2.pdf
trending-flavors-and-ingredients-in-salty-snacks-us-2024_Redacted-V2.pdf
 
WSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfWSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdf
 
business environment micro environment macro environment.pptx
business environment micro environment macro environment.pptxbusiness environment micro environment macro environment.pptx
business environment micro environment macro environment.pptx
 
Planetary and Vedic Yagyas Bring Positive Impacts in Life
Planetary and Vedic Yagyas Bring Positive Impacts in LifePlanetary and Vedic Yagyas Bring Positive Impacts in Life
Planetary and Vedic Yagyas Bring Positive Impacts in Life
 
Onemonitar Android Spy App Features: Explore Advanced Monitoring Capabilities
Onemonitar Android Spy App Features: Explore Advanced Monitoring CapabilitiesOnemonitar Android Spy App Features: Explore Advanced Monitoring Capabilities
Onemonitar Android Spy App Features: Explore Advanced Monitoring Capabilities
 
The Bizz Quiz-E-Summit-E-Cell-IITPatna.pptx
The Bizz Quiz-E-Summit-E-Cell-IITPatna.pptxThe Bizz Quiz-E-Summit-E-Cell-IITPatna.pptx
The Bizz Quiz-E-Summit-E-Cell-IITPatna.pptx
 
Healthcare Feb. & Mar. Healthcare Newsletter
Healthcare Feb. & Mar. Healthcare NewsletterHealthcare Feb. & Mar. Healthcare Newsletter
Healthcare Feb. & Mar. Healthcare Newsletter
 
Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...
Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...
Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...
 
Welding Electrode Making Machine By Deccan Dynamics
Welding Electrode Making Machine By Deccan DynamicsWelding Electrode Making Machine By Deccan Dynamics
Welding Electrode Making Machine By Deccan Dynamics
 
Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03
 
Jewish Resources in the Family Resource Centre
Jewish Resources in the Family Resource CentreJewish Resources in the Family Resource Centre
Jewish Resources in the Family Resource Centre
 
Technical Leaders - Working with the Management Team
Technical Leaders - Working with the Management TeamTechnical Leaders - Working with the Management Team
Technical Leaders - Working with the Management Team
 
Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.
 
1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf
 
Darshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdfDarshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdf
 
Go for Rakhi Bazaar and Pick the Latest Bhaiya Bhabhi Rakhi.pptx
Go for Rakhi Bazaar and Pick the Latest Bhaiya Bhabhi Rakhi.pptxGo for Rakhi Bazaar and Pick the Latest Bhaiya Bhabhi Rakhi.pptx
Go for Rakhi Bazaar and Pick the Latest Bhaiya Bhabhi Rakhi.pptx
 
1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf
 
WSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdfWSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdf
 
How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...
How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...
How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...
 
Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...
Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...
Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...
 

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 /