Your SlideShare is downloading. ×
0
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Selenium
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Selenium

4,634

Published on

My presentation on selenium

My presentation on selenium

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,634
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
0
Comments
0
Likes
7
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Automated web application testing using Selenium - Muthukrishnan Shanmugam Automated web application testing using Selenium - Muthukrishnan Shanmugam
  • 2. <ul><li>Browser based suite of tools to automate web application testing across many platforms. </li></ul><ul><li>Selenium is developed by ThoughtWorks. </li></ul><ul><li>An open source released under the Apache 2.0 license. </li></ul><ul><li>Developed in JavaScript/DHTML. </li></ul><ul><li>Official site - http://selenium.openqa.org/ </li></ul>Introduction Overview
  • 3. <ul><li>Alerts </li></ul><ul><li>Same origin policy </li></ul><ul><li>File uploads </li></ul><ul><li>and more.. </li></ul>Overview <ul><li>Supports testing apps built by web 2.0 technologies like AJAX </li></ul><ul><li>Suitable for Functionality and Browser Compatibility Testing </li></ul><ul><li>Table/Keyword driven Testing </li></ul><ul><li>Testing can be controlled by many programming languages and testing frameworks </li></ul><ul><li>Faster Test Execution </li></ul>Thumbs Up  Thumbs Down 
  • 4. <ul><li>Selenium IDE </li></ul><ul><li>Selenium Core </li></ul><ul><li>Selenium Remote Control (RC) </li></ul><ul><li>Selenium Grid </li></ul><ul><li>Selenium on Rails </li></ul><ul><li>Cubic test </li></ul>Selenium Products Overview
  • 5. Selenium IDE 1.0b2
  • 6. Introduction Overview <ul><li>Selenium IDE is a tool to test functionality of web applications </li></ul><ul><li>Acts as a complete IDE for selenium tests, as it lets the user to record, playback, </li></ul><ul><li>edit and debug tests, view test logs and results </li></ul><ul><li>Runs in the browser, Implemented as Firefox extension. </li></ul><ul><li>Platform support </li></ul><ul><ul><li>Only Firefox 2+ browsers </li></ul></ul><ul><ul><li>All Operating systems </li></ul></ul><ul><ul><li>Programming Languages – HTML, C#, Java, Perl, PHP, Python and Ruby </li></ul></ul>
  • 7. <ul><li>Method 1 – From open qa’s site </li></ul><ul><li> http://selenium-ide.openqa.org/download.jsp </li></ul><ul><li>Method 2 – From Mozilla’s Add-ons site </li></ul><ul><li> https://addons.mozilla.org/en-US/firefox/addon/2079 </li></ul>Installing Selenium IDE 1.0b2 Overview Exploring Selenium IDE 1.0b2 <ul><li>Run and Record toolbar </li></ul><ul><li>Script pane </li></ul><ul><li>Lower pane </li></ul><ul><li>Menu </li></ul>
  • 8. <ul><li>Commands – tells sel. What to do </li></ul><ul><ul><li>Actions – Manipulates the state of application </li></ul></ul><ul><ul><li>e.g. click/clickAndWait, type/typeAndWait </li></ul></ul><ul><ul><li>Accessors – Examines the state of application and stores the results in a variable </li></ul></ul><ul><ul><li> e.g. storeTitle </li></ul></ul><ul><ul><li>Assertions – Verifies the state of application and conforms to what is expected. All </li></ul></ul><ul><ul><li>selenium assertions can be used in 3 modes ‘assert’, ‘verify’ and ‘waitFor’. </li></ul></ul><ul><li>Element Locators – tells sel. Which HTML element a command refers to </li></ul><ul><li>Locators could be of id, name, dom, xpath, link or css </li></ul><ul><li>Patterns – can be used for various reasons. e.g. can be used to specify an expected value </li></ul><ul><li>Patterns could be of values, exact/reg-ex/glob string </li></ul>Script pane – in detail Overview
  • 9. <ul><li>By Default, the test is recorded as a Selenese HTML script </li></ul><ul><li>Recording can be done in any of the supported programming languages and same </li></ul><ul><li>could be exported for editing. </li></ul><ul><li>P.S : Selenium IDE does not allow the user to run scripts other than Selenese HTML </li></ul>Recording Overview Playing Back <ul><li>Scripts could be played back with the following options </li></ul><ul><ul><li>Playing the entire Test suite </li></ul></ul><ul><ul><li>Playing the current Test case </li></ul></ul><ul><ul><li>Playing with Sel. IDE Test runner </li></ul></ul><ul><ul><li>Playing by the speed of user’s choice </li></ul></ul>
  • 10. <ul><li>Plan your Test </li></ul><ul><li>Prepare Manual Test Cases </li></ul><ul><li>Record the Base scripts </li></ul><ul><li>Play it back for verification </li></ul><ul><li>Convert Manual Test cases into Automation Test Scripts (Editing / Inserting Test </li></ul><ul><li>scripts) </li></ul><ul><li>Run the Test scripts </li></ul><ul><li>Analyze the Test results </li></ul>Testing Functionality of a simple web app. using Selenium IDE Overview
  • 11. Sample Test run using Selenium IDE…..
  • 12. Selenium Core 0.8.3
  • 13. Introduction Overview <ul><li>Selenium Core is a tool to Test Functionality and Browser Compatibility of web </li></ul><ul><li>applications </li></ul><ul><li>Runs directly in the browser and lets the user only to run the tests </li></ul><ul><li>Platform support </li></ul><ul><ul><li>Browsers – FF 3, FF 2, IE 7, Safari 3, Safari 2, Opera 9, Opera 8 </li></ul></ul><ul><ul><li>OS – Windows, OS X, Linux, Solaris </li></ul></ul><ul><li>How ever works on any platform with JavaScript enabled browsers </li></ul>
  • 14. Installing Selenium Core 0.8.3 Overview <ul><li>Download Sel. Core from http://selenium-core.openqa.org/download.jsp </li></ul><ul><li>Make it available from the same web server as the application you want to test </li></ul><ul><li>If you can’t modify the application’s web server you want to test, then core isn’t the right </li></ul><ul><li>tool for you ! </li></ul><ul><li>Open Sel. Test runner as a http page and NOT as a file </li></ul>
  • 15. How Selenium core works? Overview <ul><li>Uses JavaScript and Iframes to embed a Test Automation engine in your browser </li></ul><ul><li>Why I’ve to Install Sel.core on the same place as web server is? </li></ul>
  • 16. Exploring Selenium Test Runner 0.8.3 Overview
  • 17. Testing using Selenium Core Overview <ul><li>Generate Test Scripts using Selenium IDE </li></ul><ul><li>Place the Test Suite in Tests folder of Sel. Core </li></ul><ul><li>Give away the Test suite’s path in Test Runner and click Go </li></ul><ul><li>Run the Test Suite / Test Cases </li></ul><ul><li>Analyze the Test Results for its Functionality </li></ul><ul><li>Analyze the Test Results for its Browser Compatibility </li></ul>
  • 18. Overview HTA mode <ul><li>HTA mode works only with IE on windows, can’t use it for testing with any other browsers </li></ul><ul><li>HTA file is a special type of HTML file, that is allowed to violate the same origin policy </li></ul><ul><li>You don’t have to install core onto the web server </li></ul><ul><li>Just open TestRunner.hta file in the Sel. Core installation folder, you’re now free to run your tests </li></ul><ul><li>against any website </li></ul>
  • 19. Selenium Remote Control 0.9.2
  • 20. Introduction Overview <ul><li>Selenium Remote Control is a tool to test the functionality and browser </li></ul><ul><li>compatibility of web applications </li></ul><ul><li>Test scripts can be generated in programming languages of user choice </li></ul><ul><li>Platform support </li></ul><ul><ul><li>Programming Languages - HTML, C#, Java, Perl, PHP, Python and Ruby </li></ul></ul><ul><ul><li>Browsers – FF 3, FF 2, IE 7, Safari 3, Safari 2, Opera 9, Opera 8 </li></ul></ul><ul><ul><li>OS – Windows, OS X, Linux, Solaris </li></ul></ul><ul><li>How ever works on any platform with JavaScript enabled browsers </li></ul><ul><li>RC is great for testing complex AJAX based web UI under a continuous integration system </li></ul>
  • 21. Selenium RC Architecture Overview
  • 22. Overview <ul><li>RC client driver reaches out the RC server </li></ul><ul><li>RC server launches a browser </li></ul><ul><li>RC server bundles selenium Core and automatically loads into the browser </li></ul><ul><li>TestRunner in core will now open AUT </li></ul><ul><li>The Test script starts running </li></ul>How Selenium RC works?
  • 23. Installing Selenium RC 0.9.2 Overview <ul><li>Download selenium RC from http://selenium-rc.openqa.org/download.html </li></ul><ul><li>Install the latest version of JRE and add it to path env. variable </li></ul><ul><li>check using java –version in the command prompt </li></ul><ul><li>Install the latest version of PERL </li></ul><ul><li>Install selenium PERL client driver, run the foll. commands in PERL client driver directory </li></ul><ul><ul><li>perl makefile.pl – you’ll now find an auto-generated make file </li></ul></ul><ul><ul><li>nmake install (for windows) – PERL modules will be downloaded from CPAN </li></ul></ul>
  • 24. Testing options on Selenium RC Overview <ul><li>Testing without Coding </li></ul><ul><ul><li>Normal Mode </li></ul></ul><ul><ul><li>Interactive Mode – for rapid prototyping of tests </li></ul></ul><ul><ul><li>Proxy Injection Mode – Experimental feature for now </li></ul></ul><ul><li>Programming the Test using any of the supported Programming Languages </li></ul>
  • 25. A Sample Test using RC in Interactive mode Overview <ul><li>Start the server in interactive mode the cmd line - java -jar selenium-server.jar -interactive </li></ul><ul><li>Launch the browser - cmd=getNewBrowserSession&amp;1=*iexplore&amp;2=http://www.google.com </li></ul><ul><li> (or) </li></ul><ul><li>cmd=getNewBrowserSession&amp;1=*firefox&amp;2=http://www.google.com </li></ul><ul><li>Jot down the session id; say, session id = 260113 </li></ul><ul><li>Lets do a Google search ! </li></ul><ul><ul><li>cmd=open&amp;1=http://www.google.com/webhp&amp;sessionId=260113 </li></ul></ul><ul><ul><li>cmd=type&amp;1=q&amp;2=hello world&amp;sessionId=260113 </li></ul></ul><ul><ul><li>cmd=click&amp;1=btnG&amp;sessionId=260113 </li></ul></ul><ul><li>Getting the page’s title cmd=getTitle&amp;sessionId=260113 </li></ul><ul><li>Wind up - cmd=testComplete&amp;sessionId=260113 </li></ul>
  • 26. Sample Test run using Selenium RC with PERL script…
  • 27. More on RC…. Overview <ul><li>RC circumvents Same origin policy by acting as a client-configured proxy </li></ul><ul><li>Automatically Launching other browsers </li></ul><ul><ul><li>cmd=getNewBrowserSession&amp;1=*custom c:Program </li></ul></ul><ul><ul><li> FilesNetscapeNetscapeNetscp.exe&amp;2=http://www.google.com – Must manually configure </li></ul></ul><ul><ul><li>HTTP proxy as ‘localhost:4444’ </li></ul></ul><ul><li>Running Tests under multi-window - java -jar selenium-server.jar -multiWindow </li></ul>
  • 28. Selenium Grid 1.0.1
  • 29. Introduction Overview <ul><li>Selenium Grid is a tool that dramatically speeds up end-to-end web testing </li></ul><ul><li>Transparently distributes your tests on multiple machines, so that tests run on parallel </li></ul><ul><li>Cuts down time required for running in-browser test suites </li></ul>How Selenium Grid works?
  • 30. Installing Selenium Grid 1.0.1 Overview <ul><li>Hub machine </li></ul><ul><ul><li>Install the latest version of JRE and JDK, check using java -version </li></ul></ul><ul><ul><li>Install the latest version of ANT </li></ul></ul><ul><ul><ul><li>Download the binary distribution </li></ul></ul></ul><ul><ul><ul><li>Add the ANT folder to PATH env. Variable </li></ul></ul></ul><ul><ul><ul><li>check using ant –version </li></ul></ul></ul><ul><ul><li>Download the latest Selenium Grid from http://selenium-grid.openqa.org/download.html </li></ul></ul><ul><ul><li>Transparently distributes your tests on multiple machines, so that tests run on parallel </li></ul></ul><ul><ul><li>Go to the root of Selenium Grid directory validate the installation – ant sanity-check </li></ul></ul><ul><li>Remote control machines should have Selenium RCs installed </li></ul>
  • 31. Running Tests in Sequence on Firefox on a single machine Overview <ul><li>Launch Hub by using ant launch-hub in Hub machine </li></ul><ul><li>Check whether that the Hub is running by looking at http://localhost:4444/console </li></ul><ul><li>Launch RC in a new terminal using ant launch-remote-control in Hub machine </li></ul><ul><li>Now check http://localhost:4444/console for a running remote control </li></ul><ul><li>Run demo in sequence using ant run-demo-in-sequence in a new terminal </li></ul>
  • 32. Running Tests in Parallel on Firefox on a single machine Overview <ul><li>Launch Hub by using ant launch-hub in Hub machine </li></ul><ul><li>Check whether that the Hub is running by looking at http://localhost:4444/console </li></ul><ul><li>Launch RC in a new terminal using ant launch-remote-control in Hub machine </li></ul><ul><li>Launch 3 more RCs in separate terminals ant -Dport=5556 launch-remote-control, ant -Dport=5557 </li></ul><ul><li>launch-remote-control, ant -Dport=5558 launch-remote-control </li></ul><ul><li>Now check http://localhost:4444/console for all four running remote controls </li></ul><ul><li>Run demo in parallel using ant run-demo-in-parallel in a new terminal </li></ul>
  • 33. Running Tests in Parallel on Multiple Machines Overview
  • 34. Running Tests with RCc Providing different environment Overview
  • 35. Thank you !!! Overview

×