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

Mais conteúdo relacionado

Mais procurados

Angular directives and pipes
Angular directives and pipesAngular directives and pipes
Angular directives and pipesKnoldus Inc.
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorialRohit Gupta
 
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...Simplilearn
 
Testing RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkTesting RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkMicha Kops
 
Rest API with Swagger and NodeJS
Rest API with Swagger and NodeJSRest API with Swagger and NodeJS
Rest API with Swagger and NodeJSLuigi Saetta
 
Step by step - Selenium 3 web-driver - From Scratch
Step by step - Selenium 3 web-driver - From Scratch  Step by step - Selenium 3 web-driver - From Scratch
Step by step - Selenium 3 web-driver - From Scratch Haitham Refaat
 
Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced RoutingLaurent Duveau
 
JavaScript Fetch API
JavaScript Fetch APIJavaScript Fetch API
JavaScript Fetch APIXcat Liu
 
An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.jsPagepro
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of SignalsCoding Academy
 
API Testing. Streamline your testing process.
API Testing. Streamline your testing process.API Testing. Streamline your testing process.
API Testing. Streamline your testing process.Andrey Oleynik
 
Designing Effective Tests with React Testing Library - React Day Berlin 2022
Designing Effective Tests with React Testing Library - React Day Berlin 2022Designing Effective Tests with React Testing Library - React Day Berlin 2022
Designing Effective Tests with React Testing Library - React Day Berlin 2022Josh Justice
 
Build RESTful API Using Express JS
Build RESTful API Using Express JSBuild RESTful API Using Express JS
Build RESTful API Using Express JSCakra Danu Sedayu
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesWebStackAcademy
 

Mais procurados (20)

Angular directives and pipes
Angular directives and pipesAngular directives and pipes
Angular directives and pipes
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorial
 
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
 
Testing RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkTesting RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured framework
 
Angular
AngularAngular
Angular
 
Rest API with Swagger and NodeJS
Rest API with Swagger and NodeJSRest API with Swagger and NodeJS
Rest API with Swagger and NodeJS
 
Step by step - Selenium 3 web-driver - From Scratch
Step by step - Selenium 3 web-driver - From Scratch  Step by step - Selenium 3 web-driver - From Scratch
Step by step - Selenium 3 web-driver - From Scratch
 
Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced Routing
 
Protractor overview
Protractor overviewProtractor overview
Protractor overview
 
Application Testing Suite
Application Testing SuiteApplication Testing Suite
Application Testing Suite
 
JavaScript Fetch API
JavaScript Fetch APIJavaScript Fetch API
JavaScript Fetch API
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.js
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of Signals
 
API Testing. Streamline your testing process.
API Testing. Streamline your testing process.API Testing. Streamline your testing process.
API Testing. Streamline your testing process.
 
Designing Effective Tests with React Testing Library - React Day Berlin 2022
Designing Effective Tests with React Testing Library - React Day Berlin 2022Designing Effective Tests with React Testing Library - React Day Berlin 2022
Designing Effective Tests with React Testing Library - React Day Berlin 2022
 
Build RESTful API Using Express JS
Build RESTful API Using Express JSBuild RESTful API Using Express JS
Build RESTful API Using Express JS
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 

Destaque

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
 
Smarter Testing With Spock
Smarter Testing With SpockSmarter Testing With Spock
Smarter Testing With SpockIT Weekend
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEBHoward Lewis Ship
 
End-to-End Test Automation for Both Horizontal and Vertical Scale
End-to-End Test Automation for Both Horizontal and Vertical ScaleEnd-to-End Test Automation for Both Horizontal and Vertical Scale
End-to-End Test Automation for Both Horizontal and Vertical ScaleErdem YILDIRIM
 
Smidig 2016 - Do you trust your test?
Smidig 2016 - Do you trust your test?Smidig 2016 - Do you trust your test?
Smidig 2016 - Do you trust your test?Cecilie Haugstvedt
 
Idiomatic spock
Idiomatic spockIdiomatic spock
Idiomatic spockGR8Conf
 
Acceptance testing with Geb
Acceptance testing with GebAcceptance testing with Geb
Acceptance testing with GebRichard Paul
 
Design Patterns from 10K feet
Design Patterns from 10K feetDesign Patterns from 10K feet
Design Patterns from 10K feetNaresha K
 
Cloud browser testing with Gradle and Geb
Cloud browser testing with Gradle and GebCloud browser testing with Gradle and Geb
Cloud browser testing with Gradle and GebDavid Carr
 
Java beyond Java - from the language to platform
Java beyond Java - from the language to platformJava beyond Java - from the language to platform
Java beyond Java - from the language to platformNaresha K
 
Better Selenium Tests with Geb - Selenium Conf 2014
Better Selenium Tests with Geb - Selenium Conf 2014Better Selenium Tests with Geb - Selenium Conf 2014
Better Selenium Tests with Geb - Selenium Conf 2014Naresha K
 
Functional testing your Grails app with GEB
Functional testing your Grails app with GEBFunctional testing your Grails app with GEB
Functional testing your Grails app with GEBGR8Conf
 
Westrich spock-assets-gum
Westrich spock-assets-gumWestrich spock-assets-gum
Westrich spock-assets-gumBrian Westrich
 

Destaque (20)

Taming Functional Web Testing with Spock and Geb
Taming Functional Web Testing with Spock and GebTaming Functional Web Testing with Spock and Geb
Taming Functional Web Testing with Spock and Geb
 
Smarter Testing With Spock
Smarter Testing With SpockSmarter Testing With Spock
Smarter Testing With Spock
 
Spock framework
Spock frameworkSpock framework
Spock framework
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEB
 
End-to-End Test Automation for Both Horizontal and Vertical Scale
End-to-End Test Automation for Both Horizontal and Vertical ScaleEnd-to-End Test Automation for Both Horizontal and Vertical Scale
End-to-End Test Automation for Both Horizontal and Vertical Scale
 
Smidig 2016 - Do you trust your test?
Smidig 2016 - Do you trust your test?Smidig 2016 - Do you trust your test?
Smidig 2016 - Do you trust your test?
 
Spock and Geb in Action
Spock and Geb in ActionSpock and Geb in Action
Spock and Geb in Action
 
Tests en Java con Groovy y Spock
Tests en Java con Groovy y SpockTests en Java con Groovy y Spock
Tests en Java con Groovy y Spock
 
Idiomatic spock
Idiomatic spockIdiomatic spock
Idiomatic spock
 
Acceptance testing with Geb
Acceptance testing with GebAcceptance testing with Geb
Acceptance testing with Geb
 
Geb for browser automation
Geb for browser automationGeb for browser automation
Geb for browser automation
 
Design Patterns from 10K feet
Design Patterns from 10K feetDesign Patterns from 10K feet
Design Patterns from 10K feet
 
Cloud browser testing with Gradle and Geb
Cloud browser testing with Gradle and GebCloud browser testing with Gradle and Geb
Cloud browser testing with Gradle and Geb
 
Java beyond Java - from the language to platform
Java beyond Java - from the language to platformJava beyond Java - from the language to platform
Java beyond Java - from the language to platform
 
Better Selenium Tests with Geb - Selenium Conf 2014
Better Selenium Tests with Geb - Selenium Conf 2014Better Selenium Tests with Geb - Selenium Conf 2014
Better Selenium Tests with Geb - Selenium Conf 2014
 
Geb presentation
Geb presentationGeb presentation
Geb presentation
 
Spock Framework
Spock FrameworkSpock Framework
Spock Framework
 
Functional testing your Grails app with GEB
Functional testing your Grails app with GEBFunctional testing your Grails app with GEB
Functional testing your Grails app with GEB
 
What makes Geb groovy?
What makes Geb groovy?What makes Geb groovy?
What makes Geb groovy?
 
Westrich spock-assets-gum
Westrich spock-assets-gumWestrich spock-assets-gum
Westrich spock-assets-gum
 

Semelhante a Geb with spock

Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect ModelComprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect ModelvodQA
 
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
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finessemzgubin
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finessemzgubin
 
Agile NCR 2013 - Gaurav Bansal- web_automation
Agile NCR 2013 - Gaurav Bansal- web_automationAgile NCR 2013 - Gaurav Bansal- web_automation
Agile NCR 2013 - Gaurav Bansal- web_automationAgileNCR2013
 
淺談 Geb 網站自動化測試(JCConf 2014)
淺談 Geb 網站自動化測試(JCConf 2014)淺談 Geb 網站自動化測試(JCConf 2014)
淺談 Geb 網站自動化測試(JCConf 2014)Kyle Lin
 
Groovy and Grails intro
Groovy and Grails introGroovy and Grails intro
Groovy and Grails introMiguel Pastor
 
ASP.NET MVC Workshop for Women in Technology
ASP.NET MVC Workshop for Women in TechnologyASP.NET MVC Workshop for Women in Technology
ASP.NET MVC Workshop for Women in TechnologyMałgorzata Borzęcka
 
T 0230 Google Wave Powered By Gwt
T 0230 Google Wave Powered By GwtT 0230 Google Wave Powered By Gwt
T 0230 Google Wave Powered By Gwtsupertoy2015
 
Play Framework on Google App Engine
Play Framework on Google App EnginePlay Framework on Google App Engine
Play Framework on Google App EngineFred Lin
 
Geb+spock: let your functional tests live long and prosper
Geb+spock: let your functional tests live long and prosperGeb+spock: let your functional tests live long and prosper
Geb+spock: let your functional tests live long and prosperEsther Lozano
 
Grunt Continuous Development of the Front End Tier
Grunt Continuous Development of the Front End TierGrunt Continuous Development of the Front End Tier
Grunt Continuous Development of the Front End TierErick Brito
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by ExampleNalin Goonawardana
 
Google App Engine With Java And Groovy
Google App Engine With Java And GroovyGoogle App Engine With Java And Groovy
Google App Engine With Java And GroovyKen Kousen
 
Griffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java TechnologyGriffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java TechnologyJames Williams
 
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
 
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для брауз...
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для брауз...QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для брауз...
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для брауз...QAFest
 
OSGi enRoute Unveiled - P Kriens
OSGi enRoute Unveiled - P KriensOSGi enRoute Unveiled - P Kriens
OSGi enRoute Unveiled - P Kriensmfrancis
 

Semelhante a Geb with spock (20)

Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect ModelComprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
 
Stanislaw potoczny kra_qa_21.01.20
Stanislaw potoczny kra_qa_21.01.20Stanislaw potoczny kra_qa_21.01.20
Stanislaw potoczny kra_qa_21.01.20
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finesse
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finesse
 
Agile NCR 2013 - Gaurav Bansal- web_automation
Agile NCR 2013 - Gaurav Bansal- web_automationAgile NCR 2013 - Gaurav Bansal- web_automation
Agile NCR 2013 - Gaurav Bansal- web_automation
 
淺談 Geb 網站自動化測試(JCConf 2014)
淺談 Geb 網站自動化測試(JCConf 2014)淺談 Geb 網站自動化測試(JCConf 2014)
淺談 Geb 網站自動化測試(JCConf 2014)
 
Groovy and Grails intro
Groovy and Grails introGroovy and Grails intro
Groovy and Grails intro
 
Grails 101
Grails 101Grails 101
Grails 101
 
ASP.NET MVC Workshop for Women in Technology
ASP.NET MVC Workshop for Women in TechnologyASP.NET MVC Workshop for Women in Technology
ASP.NET MVC Workshop for Women in Technology
 
T 0230 Google Wave Powered By Gwt
T 0230 Google Wave Powered By GwtT 0230 Google Wave Powered By Gwt
T 0230 Google Wave Powered By Gwt
 
Play Framework on Google App Engine
Play Framework on Google App EnginePlay Framework on Google App Engine
Play Framework on Google App Engine
 
Geb+spock: let your functional tests live long and prosper
Geb+spock: let your functional tests live long and prosperGeb+spock: let your functional tests live long and prosper
Geb+spock: let your functional tests live long and prosper
 
Grunt Continuous Development of the Front End Tier
Grunt Continuous Development of the Front End TierGrunt Continuous Development of the Front End Tier
Grunt Continuous Development of the Front End Tier
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
 
Google App Engine With Java And Groovy
Google App Engine With Java And GroovyGoogle App Engine With Java And Groovy
Google App Engine With Java And Groovy
 
Griffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java TechnologyGriffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java Technology
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
 
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для брауз...
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для брауз...QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для брауз...
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для брауз...
 
OSGi enRoute Unveiled - P Kriens
OSGi enRoute Unveiled - P KriensOSGi enRoute Unveiled - P Kriens
OSGi enRoute Unveiled - P Kriens
 

Último

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 

Último (20)

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Geb with spock

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