Web Testen mit Selenium


Published on

Published in: Lifestyle, Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • I show here the IDE in Firefox – how it functions for a login page and the generated java file.
  • Web Testen mit Selenium

    1. 1. Selenium Automation Testing with Selenium Wien, 21. Oktober, 2010 Monica Nanu
    2. 2. Summary Selenium – General overview Risks and structuring the test project Showcase: Implementation for TEMPO
    3. 3. Selenium – General Overview What is Selenium? The Selenium components Steps in developing automation tests Future development – Selenium 2.0
    4. 4. Selenium is a suite of tools to automate web application testing across many platforms. What is Selenium Framework for automation testing tool for web applications IDE for record / playback → creation of tests → learning language DSL for writing test scripts in Java, Ruby and others Support for all major browsers Selenium components Selenium IDE Selenium Remote Control Selenium Grid Selenium – General Overview
    5. 5. ● Steps: Selenium IDE: Record and playback Selenium IDE: Export as Java code Selenium RC: Execute Java(Eclipse-Junit) Selenium GRID: distribute on various environments Selenium – General Overview
    6. 6. Selenium commands (Selenese) A set of commands that run the tests for a web- based application: check if the correct UI elements exist; check the specific content of the UI elements; check that all links are functional; check data entry field (input of data and check of the values); checks the option selection on different UI elements (radio buttons, check boxes, drop down lists); checks the form submit options; check for applications using Ajax calls. There are 3 Types of commands: Actions - commands that manage the state of the application “click link”, “select option”, Fail = the execution of the test case stops/ends, ...AndWait – a post-back is set and Selenium waits until the execution is completed Accessors – check the state of the variables that are used in Assert commands Assertions – check that the state of the aplication is exactly what and how is expected. E.g.. “the title of the page is ”abc” or that “checkbox is selected”. There are 3 methods to check: “assert” (the test stops), “verify”(error is logged and the test continues ) ” waitFor” (awaits until a restriction is aquired – used for testing applications with Selenium – General Overview
    7. 7. Client library : Transforms the Java calls into server commands, by encoding it into the “Selenese” network protocol (on top of HTTP) and sending it to the Selenium server. E.g. “start browser”, “click-to”... Server component: Listens for commands from clients (on a TCP socket) and performs actions accordingly. E.g. starting web-browser or forwarding “user interaction” to the web-browser and delivering back the result to the client. Selenium – General Overview
    8. 8. Speeds up functional testing of web-applications by leveraging the existing computing infrastructure; Allows easily running multiple tests in parallel, on multiple machines, in an heterogeneous environment; Allows running multiple instances of Selenium Remote Control in parallel. Even better, it makes all these Selenium Remote Controls appear as a single one, so the tests do not have to worry about the actual infrastructure; Selenium Grid cuts down on the time required to run a Selenium test suite to a fraction of the time that a single instance of Selenium instance would take to run. Selenium – General Overview
    9. 9. Strong Points: Open source tool for web application (no license costs, large community for support and cont. dev.); support for multi platform and multi browser in terms of coverage; DOM testing – simple and strong; The TC are stable, for mature versions; Supports testing AJAX applications; Allows building flexible testing scenarios within the power of Java. Weak Points: Error diagnoze and reporting; Upon UI changes, the scripts need update (general for all automation tools); It is state dependent (html driven); May require more knowledge (learning effort may be high in the beginning). Future and actual Selenium projects: Selenium 2.0 (Selenium + WebDriver) Drivers: HtmlUnit / Firefox / IE / Chrome Selenium – review
    10. 10. Starting point: Test Plan Functionality tree and initial evaluation of total effort (main functionalities and test cases) Manual versus Automation testing Risk evaluation Decision for the solution of automation testing GUI and usability Performance Regressions and others Main risks to evaluate for automation: No automation - The quality of the testing and the time invested The cost of development and maintenance of the automated tests Result: We implement the automation testing in a structured layered architecture using Selenium Selenium – review
    11. 11. Test Project Structure Working together with Development and QA to implement the test framework structure. separate test-framework code from the actual tests classes separating reusable, generic test-framework code from a project specific code QA Dev T e s t c l a s s e s L o g i n M o d u l e 1 M o d u l e 2 C o m m o n T e s t c l a s s e s L o g i nL o g i n M o d u l e 1M o d u l e 1 M o d u l e 2M o d u l e 2 C o m m o nC o m m o n P r o j e c t s p e c i f i c f r a m e w o r k P a g e 1 - n P a n e 1 - n C o m m o n O t h e r . . . P r o j e c t s p e c i f i c f r a m e w o r k P a g e 1 - nP a g e 1 - n P a n e 1 - nP a n e 1 - n C o m m o nC o m m o n O t h e r . . .O t h e r . . . TestFramework UtilProjectTestcases TestFramework UtilUtilProjectProjectTestcasesTestcases ) B D r i v e r H T M L E l e m e n t s P a g e O b j e c t s ) B D r i v e rB D r i v e r H T M L E l e m e n t s H T M L E l e m e n t s P a g e O b j e c t sP a g e O b j e c t s S e l e n i u m
    12. 12. Tempo Project Tempo – a story about time Purpose of the application Possible user scenarios – as acceptance tests Structure considered for testing Demo of the Tempo project
    13. 13. Identifying the page and panes objects for testing structure – Time Tracking page Time Tracking Page Time Tracking Pane Time List Pane Tag Pane Live View Pane Tempo Project
    14. 14. Diagram of tempo test project This is where QA designs the tests. complex functionalities covering the usage of the application; specific user scenario or a combination of possible user actions; validation data in one or more test classes; data driven testing, when needed. DEV and partly QA Pages - Java class for each page under test with the UI elements to be verified and all methods that are used further in the tests; Panes – Java classes for each panes identified in the pages and the verifying methods for each action; Common - generic functionality executed in more pages or all pages e.g. navigation between all pages, cleaning/ preparing the database for tests, auto login executed before testing any page, others. Adapting Selenium Elements: classes for basic HTML elements such as text field, check box, radio button, etc that encourage OO test code); Browser Driver: browser driver utility (class) that builds an abstraction layer for selenium RC for controlling the browser (e.g. start, stop) and for implementing user actions methods (e.g. click, type text); Extending the element location strategy by Injecting the entire jQuery framework into pages under test, in order to verify visibility of elements that appear after dynamic HTML or Ajax calls. Tempo Project
    15. 15. Use case: Open Time Tracking page and register the time in TEMPO application (time punch, time stamps, interval, duration). Check the results on the page. instantiate page object TimeTrackingPage and within it we: instantiate TimeTrackingPane – create new time stamp instantiate TimeListPane – test that a new time stamp is listed Instantiate TagPane – test that the new tag is loaded and displayed Instantiate LiveViewPane – test the duration totals Demo of the automation tests – explanation of the test class. Tempo Project
    16. 16. Questions
    17. 17. http://seleniumhq.org/ http://patrickwilsonwelsh.com http://www.muranosoft.com/Outsourcingblog/How-To-Use-JQuery-Instead-Of-XPath-Locators http://code.google.com/p/learning-codebases/source/browse/trunk/selenium-rc-patterns/ http://www.slideshare.net/dampy/selenium-204802 http://www.developerit.com/en/search/selenium-rc http://stackoverflow.com/questions/1464606/selenium-rc-having-problems-with-xpath-for-a-ta References
    18. 18. Monica Nanu openForce Information Technology GesmbH Dresdner Str. 108 / 3. Stock / Top 11 1200 Wien TEL +43 1 3191775 FAX +43 1 3191775-20 www.openforce.com