SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Myths and Challenges of Behaviour Driven Development
Myths and Challenges of Behaviour Driven DevelopmentMyths and Challenges of Behaviour Driven Development
Myths and Challenges of Behaviour Driven DevelopmentPankaj Nakhat
 
An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersKostas Saidis
 
CICD Pipeline Using Github Actions
CICD Pipeline Using Github ActionsCICD Pipeline Using Github Actions
CICD Pipeline Using Github ActionsKumar Shìvam
 
Documenting your REST API with Swagger - JOIN 2014
Documenting your REST API with Swagger - JOIN 2014Documenting your REST API with Swagger - JOIN 2014
Documenting your REST API with Swagger - JOIN 2014JWORKS powered by Ordina
 
Odi 12c-new-features-wp-2226353
Odi 12c-new-features-wp-2226353Odi 12c-new-features-wp-2226353
Odi 12c-new-features-wp-2226353Udaykumar Sarana
 
Defining Viewpoints for Ontology-Based DSLs
Defining Viewpoints for Ontology-Based DSLsDefining Viewpoints for Ontology-Based DSLs
Defining Viewpoints for Ontology-Based DSLsObeo
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectJadson Santos
 
What's new in selenium 4
What's new in selenium 4What's new in selenium 4
What's new in selenium 4Knoldus Inc.
 
Introduction to BDD
Introduction to BDDIntroduction to BDD
Introduction to BDDKnoldus Inc.
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.jsTechMagic
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGeoff Hoffman
 

Was ist angesagt? (20)

Introduction to WAI-ARIA
Introduction to WAI-ARIAIntroduction to WAI-ARIA
Introduction to WAI-ARIA
 
Myths and Challenges of Behaviour Driven Development
Myths and Challenges of Behaviour Driven DevelopmentMyths and Challenges of Behaviour Driven Development
Myths and Challenges of Behaviour Driven Development
 
An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java Developers
 
BDD & Cucumber
BDD & CucumberBDD & Cucumber
BDD & Cucumber
 
Cypress Testing.pptx
Cypress Testing.pptxCypress Testing.pptx
Cypress Testing.pptx
 
CICD Pipeline Using Github Actions
CICD Pipeline Using Github ActionsCICD Pipeline Using Github Actions
CICD Pipeline Using Github Actions
 
Gitlab ci-cd
Gitlab ci-cdGitlab ci-cd
Gitlab ci-cd
 
Documenting your REST API with Swagger - JOIN 2014
Documenting your REST API with Swagger - JOIN 2014Documenting your REST API with Swagger - JOIN 2014
Documenting your REST API with Swagger - JOIN 2014
 
Bdd Introduction
Bdd IntroductionBdd Introduction
Bdd Introduction
 
Odi 12c-new-features-wp-2226353
Odi 12c-new-features-wp-2226353Odi 12c-new-features-wp-2226353
Odi 12c-new-features-wp-2226353
 
Defining Viewpoints for Ontology-Based DSLs
Defining Viewpoints for Ontology-Based DSLsDefining Viewpoints for Ontology-Based DSLs
Defining Viewpoints for Ontology-Based DSLs
 
Selenium-4
Selenium-4Selenium-4
Selenium-4
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete project
 
Cucumber BDD
Cucumber BDDCucumber BDD
Cucumber BDD
 
Hands-on Helm
Hands-on Helm Hands-on Helm
Hands-on Helm
 
What's new in selenium 4
What's new in selenium 4What's new in selenium 4
What's new in selenium 4
 
Helm intro
Helm introHelm intro
Helm intro
 
Introduction to BDD
Introduction to BDDIntroduction to BDD
Introduction to BDD
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.js
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 

Kürzlich hochgeladen (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 

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