Selenium Primer
Upcoming SlideShare
Loading in...5
×
 

Selenium Primer

on

  • 13,919 views

 

Statistics

Views

Total Views
13,919
Views on SlideShare
13,887
Embed Views
32

Actions

Likes
12
Downloads
724
Comments
1

2 Embeds 32

http://reddyphp.wordpress.com 18
http://www.slideshare.net 14

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Selenium Primer Selenium Primer Presentation Transcript

    • Selenium–Functional Testing Tool by ThoughtWorks February 2007
    • Agenda
      • What is Selenium?
      • Implementing Selenium
      • Functional Primer on Selenium
      • Key FAQ’s
      • References and Contacts
      Selenium-Functional Testing Tool Selenium-Functional Testing Tool
    • What is Selenium?
      • Selenium Overview
      • What can be done with Selenium?
      • What can’t be done with Selenium?
      • Selenium Components
      • The Selenium Testing Process
      Selenium-Functional Testing Tool
    • Selenium Overview
      • Selenium is a framework for testing websites
      • Selenium tests run directly in a browser
      • A wide array of browsers supported by Selenium are Internet Explorer, Mozilla, Firefox on Windows, Linux, and Macintosh
      • Selenium uses JavaScript and I frames to embed a test automation engine in the browser
        • It work with any JavaScript-enabled browser
      • Selenium works with the following OS / Browser combinations:
      Selenium-Functional Testing Tool 1.3+ 0.8+, 0.9+, 1.0+ 1.6+, 1.7+ Not supported Mac OS X 10.3 0.8+, 0.9+, 1.0+ 1.6+, 1.7+ Red Hat Linux 0.8+, 0.9+, 1.0 1.6+, 1.7+ 6.0 Windows XP Safari Firefox Mozilla Internet Explorer
    • What can be done with Selenium?
      • Browser compatibility testing
        • Test your application to see if it works correctly on different browsers and operating systems
        • The same script can run on any Selenium platform
      • System functional testing
        • Create regression tests to verify application functionality and user acceptance
      • Integration testing
      • Run tests and see results on the same page
      • Generate Defect Reports
      • Selenium can be extended using Java scripts
      • Selenium supports handling dynamically generated elements
      • Selenium supports testing applications built using Ajax
      Selenium-Functional Testing Tool
    • What can’t be done with Selenium?
      • Data driven Testing
        • Means that scripts read data from an external storage site, for example, from a file or database, rather than use values hard-coded in the script
      • Performance Testing
      • Load Testing
      • Test drag and Drop
      Selenium-Functional Testing Tool
    • Selenium Components
      • Selenium Core
      • Selenium IDE
      • Selenium RC
      Selenium-Functional Testing Tool
    • Selenium Core
      • Selenium Core is a test tool for web applications
      • Selenium Core tests run directly in a browser , just as real users do
      • Selenium Core uses a unique mechanism which allows it to run on so many platforms
      • Selenium Core is written in pure JavaScript/DHTML
      • You can copy Selenium Core tests directly into their application web server, allowing the tests to run in any supported browser on the client-side
      • You must have write access to the machine their web application server is running on to install Selenium Core
      Selenium-Functional Testing Tool
    • Selenium-on-Rails
      • Selenium on Rails provides an easy way to test Rails application with Selenium Core
      • This plug-in does four things:
        • The Selenium Core files don’t have to pollute /public, they can stay in the Selenium gem or in /vendor/selenium
        • No need to create suite files, they are generated on the fly — one suite per directory in /test/selenium (suites can be nested)
        • Instead of writing the test cases in HTML you can use a number of better formats like selenese(.sel), Rselenese(.rsel), HTML/RHTML
        • Loading of fixtures and wiping of session (/selenium/setup)
      Selenium-Functional Testing Tool
    • Selenium IDE
      • Selenium IDE is an integrated development environment for Selenium tests
      • It is implemented as a Firefox extension, and allows user to record, edit, and debug tests
      • It includes the entire Selenium Core, allowing user to easily and quickly record and play back tests in the actual environment that they will run
      • Selenium IDE is not only recording tool: it is a complete IDE
        • You can choose to use its recording capability, or you may edit your scripts by hand
        • With autocomplete support and the ability to move commands around quickly, Selenium IDE is the ideal environment for creating Selenium tests no matter what style of tests you prefer
      • Features are:
        • Easy record and playback
        • Intelligent field selection will use IDs, names, or XPath as needed
        • Auto complete for all common Selenium commands
        • Walk through tests
        • Debug and set breakpoints
        • Save tests as HTML, Ruby scripts, or any other format
        • Support for Selenium user-extensions.js file
        • Option to automatically assert the title of every page
      Selenium-Functional Testing Tool
    • Selenium IDE Selenium-Functional Testing Tool
    • Selenium Remote Control
      • Selenium Remote Control is a test tool that allows you to write automated web application UI tests in any programming language against any HTTP website using any mainstream JavaScript-enabled browser
      • It provides a Selenium Server , which can automatically start/stop/control any supported browser. It works by using Selenium Core , a pure-HTML+JS library that performs automated tasks in JavaScript
      • The Selenium Server communicates directly with the browser using AJAX (XmlHttpRequest)
      • User can send commands directly to the Server using simple HTTP GET/POST requests; that means that user can use any programming language that can make HTTP requests to automate Selenium tests on the browser
      • Finally, the Selenium Server acts as a client-configured HTTP proxy, to stand in between the browser and user’s website which allows a Selenium-enabled browser to run JavaScript on arbitrary websites
      • The Selenium Server is great for testing complex AJAX-based web user interfaces under a Continuous Integration system
      Selenium-Functional Testing Tool
    • The Selenium Testing Modes
      • The test management with Selenium involves:
      • Selenium Core Mode
      Selenium-Functional Testing Tool
    • Selenium Core Mode
      • Selenium Core scripts, also referred to as test cases , are written in HTML using a simple table layout shown in Listing 1
      • Listing 1. Selenium test case structure <table border=&quot;1&quot;>
      • <tr>
      • <td>First command</td>
      • <td>Target</td>
      • <td>Value</td>
      • </tr>
      • <tr>
      • <td>Second command</td>
      • <td>Target</td>
      • <td>Value</td>
      • </tr>
      • </table>
      • Test runner scripts are usually deployed on the same server as the application under test (AUT). This is because the browser bot uses JavaScript's to emulate user actions. These scripts run in a restricted sandbox environment. If you need to circumvent these restrictions, use a proxy
      Selenium-Functional Testing Tool
    • Installing Selenium Selenium-Functional Testing Tool
    • Installing Selenium Selenium-Functional Testing Tool
      • Elementary knowledge of HTML
      • Working knowledge of JavaScript
      • Selenium configuration files
      Ramp up
      • http://selenium.thoughtworks.com/download.html
      How to download?
      • Click through Install
      • Installs Browser Bot – the automation engine of Selenium
      Setup Open Source, freeware License/Price http://selenium.thoughtworks.com/index.html URL
    • Browser-Based Testing Survey of Selenium with other tools Selenium-Functional Testing Tool
      • Written by Rob Marchetti. Patterned after Samie
      • The author has an alpha version for VB as well
      • Active mailing list since July 2004.
      IE Python Pamie
      • xUnit test framework designed for general web testing
      • Includes a GUI test runner front end
      • No mailing list
      • First release October 2002
      IE JavaScript IeUnit
      • Acceptance testing framework. Includes a new &quot;Internet Explorer bridge&quot; which likely plugs into the IE API
      • Built on top of JUnit and fixtures are written in Java
      • Seems to focus on HTTPUnit, which is not a browser-based technology
      • Some background in the Acceptance Testing HTML white paper
      IE XML Avignon Notes Browse Compatibility Test  Case Language Tool
    • Browser-Based Testing Survey of Selenium with other tools Selenium-Functional Testing Tool
      • Used internally at Tapster Rock in the UK
      • Active mailing list.
      IE Java Jiffie
      • Implemented in JavaScript
      • Works in several different browsers on Windows and Linux
      • Uses a FIT-like table interface and an object-based language reminiscent of Worksoft Certify and the latest release of Mercury QuickTest Pro, though it's not a complete keyword-driven framework
      • Requires extra work to avoid cross-site scripting security protections
      • Supports a variety of languages in RC mode
      • Sponsored by ThoughtWorks
      IE, Mozilla, Fire fox, Safari Table-based Selenium
      • Written by Henry Wasserman
      • Also uses Win32::GUITEST
      • Mailing list is largely inactive, but the author is reachable
      • First release was February 2003.
      IE Perl Samie Notes Browse Compatibility Test  Case Language Tool
    • Selenium Vs QTP (Industry Comparison Matrix)
      • Each category in the matrix is given a rating of 1 – 5
        • 1 = Excellent support for this functionality
        • 2 = Good support but lacking or another tool provides more effective support
        • 3 = Basic/ support only
        • 4 = This is only supported by use of an API call or third party add-in but not included in the general test tool/below average
        • 5 = No support
      Selenium-Functional Testing Tool 1 4 Object Mapping 2 3 Data functions 1 5 Database tests 1 2 Web Testing 1 3 Record & Playback QTP Selenium
    • Selenium-Functional Testing Tool Selenium Vs QTP (Industry Comparison Matrix) 25 50 Total 1 2 Object Tests 1 4 Support 2 3 Ease of use 5 1 Cost 1 3 Integration 1 3 Environment support 2 2 Extensible Language 2 2 Object Identity Tool 1 3 Object Name Map 2 5 Test/Error recovery 1 5 Image testing QTP Selenium
    • Functional Primer on Selenium
      • Getting Started
      • Installing Selenium Core
      • Writing Test Case
      • Adding Test Case to Test Suite
      • Running Test Case
      • Generating Defect Reports
      • Commands
      • Demos
      Selenium-Functional Testing Tool
    • Getting Started
        • If this is your first time using a Selenium tool, you may not want to just use Selenium Core directly; one good way to get introduced to Selenium's features is to use Selenium IDE , which embeds Selenium Core internally
        • Download Selenium IDE and you'll get Selenium Core along with it
      Selenium-Functional Testing Tool
    • Installing Selenium Core
        • To use Selenium Core, you need to make it available from the same web server as the application you want to test
          • This is a JavaScript security requirement. If you can't/won't modify the web server you want to test, Selenium Core may not be the right tool for you; you may just want to use Selenium IDE or Selenium RC instead
        • Extract the Selenium Core zip file into the DocumentRoot, htdocs, or webroot of your web server
        • Open the browser
        • Click Install to install the Selenium
      Selenium-Functional Testing Tool
    • Writing Test Case
        • A test-case is represented by an HTML document written in &quot;Selenese&quot;, containing a table with 3 columns, room enough for a command and two arguments
        • Not all commands take two arguments; in this case either leave the column blank or use a &nbsp; to make the table look better
        • Example:
      Selenium-Functional Testing Tool John Name verifytext True submitbutton click John nameField type /mypage open MyTest
    • Adding Test to Test Suite
        • Make new test case available by linking to it from the TestSuite; for example:
        • <table id=&quot;suiteTable&quot; cellpadding=&quot;1&quot; cellspacing=&quot;1&quot; border=&quot;1&quot;> <tbody>
        • <tr><td><b>Test Suite </b> </td> </tr>
        • <tr><td><a href=&quot;MyTest.html&quot;>MyTest</a></td></tr>
        • ...etc...
        • </tbody>
        • </table>
      Selenium-Functional Testing Tool
    • Run Test Case
        • Open selenium Core, following screen should be displayed:
      Selenium-Functional Testing Tool
    • Run Test Case (continued)
        • Locate the name of your test case in the Suite Panel (top left). Clicking on it should cause Selenium to load test into the Test Panel (top center). Now run the test by clicking the &quot;Selected&quot; button in the control area
        • Alternatively, click the &quot;All&quot; button to run the entire test suite
        • The Control Panel allows you to control how tests are executed
      Selenium-Functional Testing Tool
    • Generating Defect Reports
      • Click Show Log
      • Execute the script
      Selenium-Functional Testing Tool
    • Commands
      • A command is what tells Selenium what to do
      • Selenium commands come in two 'flavors', Actions and Assertions
      • Actions are commands that generally manipulate the state of the application
      • Each command call is one line in the test table of the form:
      Selenium-Functional Testing Tool Value Target Command
    • Commands (continued)
      • open ( url )
        • Opens a URL in the test frame. This accepts both relative and absolute URLs
        • The URL must be on the same site as Selenium due to security restrictions in the browser (Cross Site Scripting)
      • examples:
          • Open /mypage
          • open http://localhost/  
      • click ( elementLocator )
        • Clicks on a link, button, checkbox or radio button. If the click action causes a new page to load (like a link usually does), use &quot;clickAndWait&quot;.
      • examples:
          • Clicka Checkbox 
          • clickAndWait submitButton
          • clickAndWait anyLink 
      Selenium-Functional Testing Tool
    • Commands (continued)
      • type ( inputLocator , value )
        • Sets the value of an input field, as though you typed it in
        • Can also be used to set the value of combo boxes, check boxes, etc
      • examples:
          • Type nameField John Smith
          • typeAndWait textBoxThatSubmitsOnChange newValue 
      • select ( dropDownLocator , optionSpecifier )
        • Select an option from a drop-down, based on the optionSpecifier
        • If more than one option matches the specifier (e.g. due to the use of globs like &quot;f*b*&quot;, or due to more than one option having the same label or value), then the first matches is selected
      • examples:
          • Select dropDown Australian Dollars
          • Select dropDown index=0
          • selectAndWait currencySelector value=AUD
          • selectAndWait currencySelector label=Aus*lian D*rs
      Selenium-Functional Testing Tool
    • Commands (continued)
      • selectWindow ( windowId )
        • Selects a popup window
        • Once a popup window has been selected, all commands go to that window
        • To select the main window again, use &quot;null&quot; as the target
        • target: The id of the window to select
        • value: ignored
      • examples:
          • selectWindow myPopupWindow
          • selectWindow null 
      • close ()
        • Simulates the user clicking the &quot;close&quot; button in the titlebar of a popup window
      • examples:
          • close  
      • pause ( milliseconds )
        • Pauses the execution of the test script for a specified amount of time
        • This is useful for debugging a script or pausing to wait for some server side action
      • examples:
          • Pause 5000
          • Pause 2000 
      • For More commands go to
        • http://release.openqa.org/selenium-core/nightly/reference.html
      Selenium-Functional Testing Tool
    • Demos
        • Demo 1 – Passing simple tests
          • Click http://www.openqa.org/selenium-core/selenium/TestRunner.html?test=../ajaxdemo/TestSuite.html
        • Demo 2 – Failing Some Tests
          • Click http://www.openqa.org/selenium-core/selenium/TestRunner.html?test=../demo/failing/TestSuite.html
        • Demo 3 - Ajax Testing
          • Click http://www.openqa.org/selenium-core/selenium/TestRunner.html?test=../ajaxdemo/TestSuite.html
      Selenium-Functional Testing Tool
    • Selenium – Key FAQ’s
      • How do you create test tables?
      Selenium-Functional Testing Tool
    • Key FAQ’s
      • How do you create test tables?
        • The developers on the Selenium project use Mozilla Composer to create plain HTML text files for their tests. By default, Mozilla Composer writes very clean HTML without any extra, unnecessary markup
        • You can also use Selenium IDE to write your tests scripts
        • Another option is any text/html editor to create test tables. Future versions of Selenium may support RST (Restructured Text), or wiki-table syntax, natively. However, you are free to use another format now, as long as you remember to generate the HTML files from your source files, either during your build process or dynamically at run-time
      Selenium-Functional Testing Tool
    • References & Contacts
      • References :
      • http:// www.openqa.org /selenium
      • Contacts :
      • Sapient
        • SME: Preeti Kakkar [email_address] +91-9811550015
        • QA Practice Lead: Gurmeet Singh [email_address] 240 353 1762
      Selenium-Functional Testing Tool
    • What else?
      • Questions
      • Next steps
      • Feedback
      Selenium-Functional Testing Tool