Presentation is loading. Please wait.

Presentation is loading. Please wait.

Test Automation with Selenium. Agenda  Introduction to Selenium  Demo  An overview of the framework, and how it works  Showcase the different ways.

Similar presentations

Presentation on theme: "Test Automation with Selenium. Agenda  Introduction to Selenium  Demo  An overview of the framework, and how it works  Showcase the different ways."— Presentation transcript:

1 Test Automation with Selenium

2 Agenda  Introduction to Selenium  Demo  An overview of the framework, and how it works  Showcase the different ways of using Selenium  Limitations of Selenium

3 Selenium Introduction

4 What is Selenium?  Selenium is a robust set of tools that supports rapid development of test automation for web-based applications  Selenium is a combination of tools for functional tests, smoke tests, and integration tests of Web applications, including Rich Internet Applications (RIA, using Ajax.)  A Java Script Based so work any where  Embeds test automation engine in your browser  Supported on Multiple Browsers

5 Why Selenium ?  Cross Platform and Browser Compatibility  The beauty of doing these scripts in Selenium is that you could run these scripts after they are just written and see instantly where they may need tweaking and amending  Flexibility and Extensibility: Selenium’s strongest characteristic when compared with proprietary test automation tools and other open source solutions. Selenium-RC supports multiple programming and scripting languages.  Allows running multiple tests parallely in single/multiple browsers  Portability: Allows to record scripts in Windows and replay it in Linux without re-creating the script

6 Part 2: Demo

7 Selenium Components  Selenium IDE  Selenium RC  Selinum Grid

8 Using Selenium IDE  Integrated development environment for Selenium test  Allows you to record, edit and debug tests.

9 Selenese – The language of Selenium Commands of Selenium Selenese consists of Actions, Accessors, Element Locators and Variables Actions – Combination of Command, Target and Value Command : Scripts perform a particular action on a web application Target: Typically take element locator Value: Value for any input Example: Open - Open a URL Click – Click button, link, etc... Type – Type text in text field There are only about 6 commands you need to know to be able to automate tests. Same as a manual test case really (open, click, select, type, assert (check), wait).

10 Selenese – The language of Selenium Accessors – Accessors examine the state of the application and store the results in variables. Verification / Validation checkpoints for the tool Example: Store (locator, variables) Verify (locator, pattern) They are also used to automatically generate Assertions Assertions – Assertions are like Accessors, but they verify that the state of the application conforms to what is expected. Examples include "make sure the page title is X" and "verify that this checkbox is checked". All Selenium Assertions can be used in 3 modes 1. assert 2. verify 3. waitfor

11 Selenese – The language of Selenium Element Locator –  These can be id, name, identifier, link, xpath, etc...  Variables used in scripting Information regarding Actions, Accessors can be found in class ‘Selenium Driver’ in installed directory

12 Selenium – Locating Elements Using Firebug Tool Locating by XPath Rule 1: if value is assigned to any attribute Step 1 Inspect object Step 2 Look for first word say “Input” Step 3 start all xpath with // Step 4 [] Step attribute Step 6 value ->> Rule 2: if value is not assigned to any attribute Step 1 Inspect object Step 2 Look for first word say “a” Step 3 start all xpath with // Step 4 [] Step 5 text() Step 6 value ->> //a[text() = “Maps“] Rule 3: If two same objects are displayed on same page and you have to find out your choice of object //a[text()="Maps"]/following:: a[text()="Maps"]/]

13 Table or driver based? Table based approach fine for simple tests.  No programming required  Doesn't scale – duplication is a major issue Driver approach better for 'Real' test suites  Can develop tests in language of choice  C#, Java, Ruby, Python, Perl  Easier data management via DB / Excel

14 Using Selenium RC  Although Selenium-IDE is a Firefox only add-on, tests created in it can also be run against other browsers by using Selenium-RC and specifying the name of the test suite on the command line  Selenium-RC allows the test automation developer to use a programming language for maximum flexibility and extensibility in developing test logic  Selenium-RC provides an API (Application Programming Interface) and library for each of its supported languages: HTML, Java, C#, Perl, PHP, Python, and Ruby.

15 Architecture

16 Configuring Selenium-RC With Eclipse  Eclipse is a software that allows you to write and execute programs in many different languages. In our case we will be using Eclipse to write and execute Selenium via Java

17 Using Selenium Grid  Selenium-Grid allows the Selenium-RC solution to scale for test suites or test suites to be run in multiple environments.  With Selenium-Grid multiple instances of Selenium-RC are running on various operating system and browser configurations, each of these when launching register with a hub. When tests are sent to the hub they are then redirected to an available Selenium-RC, which will launch the browser and run the test.  This allows for running tests in parallel, with the entire test suite theoretically taking only as long to run as the longest individual test.

18 Part 3: Know Issues & Workarounds

19 Selenese – Element not found on page Potential Cause:  Can happen due to execution speed of selenium  Elements do not load on page in time Fix:  Add code in scripts which waits for elements Additional issues:  Sometime existing elements on a page are not deleted  Sometime elements on a page have same label Solution:  Obtain exact element label from source code  Label can be used in scripts for accuracy

20 Selenese – Handling of Popup Windows Steps:  Window id required for automated operation in window Use following commands for handling alert messages: Put following commands before assertalert command 1) storeAlert and value ($variableName) 2) storeAlertPresent and value ($variableName)

21 Selenese – Handling of Frames Option:  Multi-window option handles potential frame problems Cause:  At times required name of frame not obtained in recording Fix:  Obtain frame label from source code  Also can be obtained from browser URL bar

22 Agile, Automation, and Continuous Integration Practice that we decided to implement 1.Run Selenium tests as part of the build 2.Run all acceptance tests in the regression test suite with the build, daily (at a minimum). [4] 3. Run all unit tests with every build. [4] 4. Run multiple builds per day. 5. Can generate HTML reports, published to entire team 6. Helps catch bugs ASAP Addresses risk of catching bugs late in the cycle

23 Why Selenium

24  Scripting capabilities  Portability  Validation & Verification  Playback Options  Reporting Capabilities Why Selenium ?

25 Scripting Capabilities  Simplified Script Creation – In selenium, the default script is in html and it is the most common scripting language used among peoples.  Keyword driven testing  Standard Scripting Language allows you to easily create/update scripts without much programming knowledge  Object Repository is not available in selenium but it is one of the features of all Functional testing tool  Data driven Testing enables you to perform functional testing in different scenarios by just changing the test data in an external data source. Selenium supports Data driven testing  Unicode supports allows you to test multi-language deployments of your applications  Supports pattern-matching capabilities to improve test script reuse, if application changes frequently Why Selenium ?

26 Portability :  Allows you to record scripts in Windows and replay it in Linux without re-creating the scripts  Browser Abstraction Layer allows scripts recorded in one browser to be replayed in all other supported browsers  Runtime locale option lets you to simultaneously test all language versions of your application with a single script Why Selenium ?

27 Validation and Verification  Rich Library of Built in function added using the Function Generator tool. This helps you to construct function calls for specific testing requirements which include: In selenium, user has to create Built in function for their testing.  Checkpoints that include Text, GUI, XML, File and Database enable thorough validation of your web applications/web sites. In selenium, there is a similar thing for checkpoint called verify or asset. But user can't able to check for images/bitmap. If user wants to check for database then they have to create a database connection with JavaScript and put it in userextensions.js but not sure about creating check points in the database. I left the choice to the user. Why Selenium ?

28 Playback Options  Automatic/Customizable Error Recovery for unattended testing to handle unexpected window, like an ASSERT box, pop- ups, etc. But automatic error recovery for unattended testing is not available for selenium but user can write his/her own scripts to handle this.  Playback Synchronization to handle the variation in time the application takes to load a new page. Ex: In selenium ClickAndWait is a command which will wait for the page to load and start executing the next command.  Option to chain scripts for controlling the order of script execution. In selenium core, we can do the order of execution and if user wish he can execute everything as a batch file.  Multiple Play back options that enables testers to debug test errors while creating and maintaining test scripts. Selenium supports multiple play back options.  Allows execution of individual and/or groups of tests from one or many workstations.  Provision for command-line invocation allows invocation from batch files or scheduling utilities. Why Selenium ?

29 Reporting Capabilities  Clear and Powerful Reports are provided to indicate the status of the test execution.  Hyperlinks or color coding (RED color for failure) allow easy navigation through the report.  This helps you to quickly identify application failures and clearly assess application quality. Why Selenium ?

30 Compatibility Testing:  Today organizations trying to automate their web applications/web sites are looking for a uniform testing solution. This will help them to reuse test scripts to test it in different platforms/different browsers/different languages/different databases/different servers Why Selenium ?

31 Thanks

Download ppt "Test Automation with Selenium. Agenda  Introduction to Selenium  Demo  An overview of the framework, and how it works  Showcase the different ways."

Similar presentations

Ads by Google