by: kyle rogahn computer science seminar uw platteville 4/3/2012 web browser automation - geb
TRANSCRIPT
![Page 1: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/1.jpg)
BY: KYLE ROGAHNCOMPUTER SCIENCE SEMINAR
UW PLATTEVILLE4/3/2012
Web Browser Automation - Geb
![Page 2: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/2.jpg)
Introduction
Geb is a web browser automation toolJQuery + Webdriver + GroovyAdvantageous in certain web development
projectsNew: not even at version 1.0
![Page 3: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/3.jpg)
On Deck
Browser Automation – Geb at a high levelAdvantagesDisadvantagesWhat is it – the details
Webdriver Groovy Jquery Page Object Model
Example code testing
![Page 4: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/4.jpg)
Web Browser Automation
Programmatically control your web browser
Use this ability to write tests for web applications
Improved quality assurance process
![Page 5: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/5.jpg)
Advantages
Eliminate tedious manual testing Good fit for large projects
with many test cases Unit tests not enough to
catch errors Integration of complex
systems MVC example Data Access Objects –
retrieving customer information
![Page 6: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/6.jpg)
Advantages
Save time (and money) Speed up
navigation through many pages
Reduce data entry What takes a
person minutes Geb can do in seconds
![Page 7: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/7.jpg)
Advantages
Easy to learn Readability Semantics easy to figure out Going to the google home page
“To” keyword, google home page defined as an object
To GoogleHomePage Low learning curve
![Page 8: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/8.jpg)
Disadvantages
Less useful on smaller projects May cost more time than it saves Manual testing may suffice Could still use it if desired
Guaranteed Learning curve Since it’s new there’s a high chance
developers will not know it Comes down to affordability Although, learning curve is not that high
![Page 9: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/9.jpg)
Disadvantages
Configuration issues Specific environment needed
If using a compatible environment already it is easy
May be tough otherwise Grails, Maven, Gradle are suggested Switching environments may be too costly
Software Engineering Management Decisions
![Page 10: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/10.jpg)
What Makes Up Geb
WebDriver Handles automation
JQuery Used for content selection
Groovy Syntax based on this language
Page Object Model Architecture that makes Geb powerful
![Page 11: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/11.jpg)
WebDriver
Driving force behind browser automation Modifies document object model (DOM) components Control browser behavior
DOM components Interface content Buttons, text fields…etc
WebDriver by itself vs. Geb Geb is simpler, more readable, and easier to learn
![Page 12: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/12.jpg)
WebDriver Example
![Page 13: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/13.jpg)
Groovy
Dynamic programming language for the JVMSimilar to Ruby
Combined with some of the powerful features of Java Integrates well with all Java libraries
Supports mocking for unit testingEasy to learn and read
![Page 14: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/14.jpg)
Groovy Example
![Page 15: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/15.jpg)
Comparing to Ruby
Class HelloExample Def hello entity puts “Hello, #{entity}!” endEnd
def main example = HelloExample.new() example.hello(‘world’) end
![Page 16: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/16.jpg)
JQuery
Content Selection Improvement over WebDriver’s DOM content selector Important to quickly locate desired objects on a page
Ability to modify html codeEvent handlers and overwritingSupport for all major browsersSome of its syntax makes its way into Geb
![Page 17: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/17.jpg)
Jquery Example
![Page 18: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/18.jpg)
Testing Frameworks
Geb can be combined with many testing frameworks
Or used in-lineSpock is the
recommended framework Included in the Geb package Configuration: Import
geb.spock.GebSpec Clearest and most concise way
to write Geb tests
![Page 19: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/19.jpg)
In-line Geb
Go vs driver.get(…)
Assert without test framework Webdriver:
driver.getTitle() then compare using .equals
$ - Jquery sendKeys() in
WebDriver
![Page 20: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/20.jpg)
Page Object Model
Non inline Geb programs – preferredIncrease maintainability and reusabilityBased on the notion of page objects
Define a class for each page of your application
Call on page components when needed Only have to use JQuery for lookup once
Powerful!
![Page 21: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/21.jpg)
Typical Page Class
![Page 22: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/22.jpg)
Geb Testing Using Page Classes
Test specifications Specific names Readability/Maintainability
Spock framework Extra keywords to simplify
tests Do something then check
the result Are we on the right
page? Did a certain component
change?
![Page 23: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/23.jpg)
Testing Example
Go to the login pageMake sure we’re
thereTry to login as an
adminClick loginCheck if we are at
the admin page
![Page 24: BY: KYLE ROGAHN COMPUTER SCIENCE SEMINAR UW PLATTEVILLE 4/3/2012 Web Browser Automation - Geb](https://reader035.vdocuments.us/reader035/viewer/2022062314/56649d975503460f94a803c1/html5/thumbnails/24.jpg)
Conclusion
Geb is easy to read, write, learn, and modify.Saves a large amount of testing timeLarger application test coveragePage object model is powerfulEffective keywordsRead The Book of Geb
www.gebish.org Watch the selenium conference speech:
http://www.youtube.com/watch?v=T2qXCBT_QBs