1 / 24

Web Browser Automation - Geb

Web Browser Automation - Geb. By: Kyle rogahn Computer Science seminar Uw platteville 4/3/2012. Introduction. Geb is a web browser automation tool JQuery + Webdriver + Groovy Advantageous in certain web development projects New: not even at version 1.0. On Deck.

gates
Download Presentation

Web Browser Automation - Geb

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Web Browser Automation - Geb By: Kyle rogahn Computer Science seminar Uw platteville 4/3/2012

  2. Introduction Geb is a web browser automation tool JQuery + Webdriver + Groovy Advantageous in certain web development projects New: not even at version 1.0

  3. On Deck • Browser Automation – Geb at a high level • Advantages • Disadvantages • What is it – the details • Webdriver • Groovy • Jquery • Page Object Model • Example code • testing

  4. Web Browser Automation Programmatically control your web browser Use this ability to write tests for web applications Improved quality assurance process

  5. 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

  6. Advantages • Save time (and money) • Speed up navigation through many pages • Reduce data entry • What takes a person minutes Geb can do in seconds

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

  8. 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

  9. 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

  10. 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

  11. 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

  12. WebDriver Example

  13. Groovy • Dynamic programming language for the JVM • Similar to Ruby • Combined with some of the powerful features of Java • Integrates well with all Java libraries • Supports mocking for unit testing • Easy to learn and read

  14. Groovy Example

  15. Comparing to Ruby Class HelloExample Def hello entity puts “Hello, #{entity}!” end End def main example = HelloExample.new() example.hello(‘world’) end

  16. JQuery • Content Selection • Improvement over WebDriver’s DOM content selector • Important to quickly locate desired objects on a page • Ability to modify html code • Event handlers and overwriting • Support for all major browsers • Some of its syntax makes its way into Geb

  17. Jquery Example

  18. Testing Frameworks • Geb can be combined with many testing frameworks • Or used in-line • Spock is the recommended framework • Included in the Geb package • Configuration: Import geb.spock.GebSpec • Clearest and most concise way to write Geb tests

  19. In-line Geb • Go vsdriver.get(…) • Assert without test framework • Webdriver: driver.getTitle() then compare using .equals • $ - Jquery • sendKeys() in WebDriver

  20. Page Object Model • Non inline Geb programs – preferred • Increase maintainability and reusability • Based 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!

  21. Typical Page Class

  22. 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?

  23. Testing Example Go to the login page Make sure we’re there Try to login as an admin Click login Check if we are at the admin page

  24. Conclusion • Geb is easy to read, write, learn, and modify. • Saves a large amount of testing time • Larger application test coverage • Page object model is powerful • Effective keywords • Read The Book of Geb • www.gebish.org • Watch the selenium conference speech: • http://www.youtube.com/watch?v=T2qXCBT_QBs

More Related