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

Painless JavaScript Testing with Jest
Painless JavaScript Testing with JestPainless JavaScript Testing with Jest
Painless JavaScript Testing with JestMichał Pierzchała
 
Building CI/CD Pipelines with Jenkins and Kubernetes
Building CI/CD Pipelines with Jenkins and KubernetesBuilding CI/CD Pipelines with Jenkins and Kubernetes
Building CI/CD Pipelines with Jenkins and KubernetesJanakiram MSV
 
Pipeline based deployments on Jenkins
Pipeline based deployments  on JenkinsPipeline based deployments  on Jenkins
Pipeline based deployments on JenkinsKnoldus Inc.
 
Getting started with Jenkins
Getting started with JenkinsGetting started with Jenkins
Getting started with JenkinsEdureka!
 
Git with bitbucket
Git with bitbucketGit with bitbucket
Git with bitbucketSumin Byeon
 
Continuous integration using Jenkins and Sonar
Continuous integration using Jenkins and SonarContinuous integration using Jenkins and Sonar
Continuous integration using Jenkins and SonarPascal Larocque
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with seleniumTzirla Rozental
 
Simply your Jenkins Projects with Docker Multi-Stage Builds
Simply your Jenkins Projects with Docker Multi-Stage BuildsSimply your Jenkins Projects with Docker Multi-Stage Builds
Simply your Jenkins Projects with Docker Multi-Stage BuildsEric Smalling
 
Getting started with Next.js
Getting started with Next.jsGetting started with Next.js
Getting started with Next.jsGökhan Sarı
 
Web assembly - Future of the Web
Web assembly - Future of the WebWeb assembly - Future of the Web
Web assembly - Future of the WebCodeValue
 

Mais procurados (20)

Painless JavaScript Testing with Jest
Painless JavaScript Testing with JestPainless JavaScript Testing with Jest
Painless JavaScript Testing with Jest
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
Jenkins-CI
Jenkins-CIJenkins-CI
Jenkins-CI
 
Building CI/CD Pipelines with Jenkins and Kubernetes
Building CI/CD Pipelines with Jenkins and KubernetesBuilding CI/CD Pipelines with Jenkins and Kubernetes
Building CI/CD Pipelines with Jenkins and Kubernetes
 
Pipeline based deployments on Jenkins
Pipeline based deployments  on JenkinsPipeline based deployments  on Jenkins
Pipeline based deployments on Jenkins
 
Ansible 101
Ansible 101Ansible 101
Ansible 101
 
Getting started with Jenkins
Getting started with JenkinsGetting started with Jenkins
Getting started with Jenkins
 
Git with bitbucket
Git with bitbucketGit with bitbucket
Git with bitbucket
 
JVM++: The Graal VM
JVM++: The Graal VMJVM++: The Graal VM
JVM++: The Graal VM
 
Java 9 Features
Java 9 FeaturesJava 9 Features
Java 9 Features
 
GraalVM
GraalVMGraalVM
GraalVM
 
Continuous integration using Jenkins and Sonar
Continuous integration using Jenkins and SonarContinuous integration using Jenkins and Sonar
Continuous integration using Jenkins and Sonar
 
Jenkins Overview
Jenkins OverviewJenkins Overview
Jenkins Overview
 
Apache Maven
Apache MavenApache Maven
Apache Maven
 
Gradle
GradleGradle
Gradle
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
 
Simply your Jenkins Projects with Docker Multi-Stage Builds
Simply your Jenkins Projects with Docker Multi-Stage BuildsSimply your Jenkins Projects with Docker Multi-Stage Builds
Simply your Jenkins Projects with Docker Multi-Stage Builds
 
Getting started with Next.js
Getting started with Next.jsGetting started with Next.js
Getting started with Next.js
 
Web assembly - Future of the Web
Web assembly - Future of the WebWeb assembly - Future of the Web
Web assembly - Future of the Web
 

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
 
Spock - the next stage of unit testing
Spock - the next stage of unit testingSpock - the next stage of unit testing
Spock - the next stage of unit testingjugkaraganda
 

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
 
Spock Framework
Spock FrameworkSpock Framework
Spock Framework
 
Functional testing your Grails app with GEB
Functional testing your Grails app with GEBFunctional testing your Grails app with GEB
Functional testing your Grails app with GEB
 
What makes Geb groovy?
What makes Geb groovy?What makes Geb groovy?
What makes Geb groovy?
 
Westrich spock-assets-gum
Westrich spock-assets-gumWestrich spock-assets-gum
Westrich spock-assets-gum
 
Spock - the next stage of unit testing
Spock - the next stage of unit testingSpock - the next stage of unit testing
Spock - the next stage of unit testing
 

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

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
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
 

Último (20)

+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...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
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?
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 

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