Selenium (1)

38
Selenium – Testing Tool Seleniumonlinetraining.in fo

description

SELENIUM COURSE CONTENT: Course Description Within fast moving agile software development teams it becomes important to test user interfaces as they are being coded. Automated Testing techniques using Selenium 2 allow for test replay of important features as development progresses. Selenium IDE and Selenium Web Driver are important tools for any tester or developer to use in ensuring software quality and making changes with confidence. This interactive, hands-on workshop provides an understanding and advanced techniques in the use of Selenium 2 with hands on practice. The practice exercises are tailored to various skill levels and type of application being tested, from simple forms to complex web applications. Objectives: The class will teach participants to: Understand trade-offs of automated vs. manual testing. Record, edit and play back Selenium IDE tests against multiple types of web applications. Minimize test failure due to normal changes to code. Understanding of basic Selenium commands to get through common issue with web applications. Use of Eclipse to run tests individually and as a group to generate test failure reports. Learn how to help developers understand the importance of making applications more testable to improve usability. Topics: Overview of automated testing Selenium Suite Overview Selenium 2 Limitations Selenium IDE HTML Locator strategy and false test failure Firefox Firebug and reading HTML Selenium Web Driver setup Eclipse and JUnit (Don't Panic it's just code) Convert Selenium IDE tests into Selenium 2 Java WebDriver tests Working with unsupported commands from Selenium IDE Dealing with security and certificates Selenium Web Driver practice workshop Learn how to test in multiple browsers and generate metrics and reports Discussion of setting up Selenium Web Driver for continuous integration Bonus Features: Sample Selenium Web Driver code Scripts to run JUnit test suites on multiple browsers and generate reports and metrics List of web resources and blogs for reference Laminated CSS selector cheat sheet Laminated Selenium 2 command reference Courses Offered in Our Training Institute: 1)Msbi 2)Dotnet 3)SharePoint 2010 4)Testing TOOLs - QTP, QC , Load Runner, Selenium 5)SQL SERVER Visit for the course Details www.mindqonline.com Mail us for details: [email protected] Call me at: +91-9502991277.

Transcript of Selenium (1)

Page 1: Selenium (1)

Selenium – Testing Tool

Seleniumonlinetraining.info

Page 2: Selenium (1)

What is Selenium?

• Selenium is a robust set of tools that supports rapid development of test automation for web-based applications.

• Works anywhere JavaScript is supported

• Hooks for many other languages - Java, Ruby, Python

• Can simulate a user navigating through pages and then assert for specific marks on the pages

• All you need to really know is HTML to start using it right away

seleniumonlinetraining.info

Page 3: Selenium (1)

Selenium

• You can use open source - Selenium tool

• Selenium IDE is a plug-in to Firefox to record and playback tests (like WinRunner, QTP).

• You can then export the recorded test in most language e.g. HTML, Java , .NET , Perl , Ruby etc.

• The exported test can be run in any browser and any platform using "selenium remote control".

seleniumonlinetraining.info

Page 4: Selenium (1)

Where to get it?

• You can use Selenium-Core and customize everything – deprecated.

• But it is easier to just get a Firefox plug-in “Selenium-IDE” that helps you “record” test Cases.

• You can record how an app is being used and then playback those recordings followed by asserts.

• Get everything at:www.seleniumonlinetraining.infoseleniumonlinetraining.info

Page 5: Selenium (1)

Selenium Components

seleniumonlinetraining.info

Page 6: Selenium (1)

Selenium-IDE• Integrated Development Environment for building Selenium test

cases. • Operates as a Firefox add-on and provides an interface for

developing and running individual test cases or entire test suites.

• Selenium-IDE has a recording feature, which will keep account of user actions as they are performed and store them as a reusable script to play back.

• It also has a context menu (right-click) integrated with the Firefox browser, which allows the user to pick from a list of assertions and verifications for the selected location.

• Offers full editing of test cases.• Although it is a Firefox only add-on, tests created in it can also

be run against other browsers by using Selenium-RC & specifying the name of the test suite on the command line.

Page 7: Selenium (1)

Selenium-RC (Remote Control)

• Selenium-RC provides an API (Application Programming Interface) and library for each of its supported languages: HTML, Java, C#, Perl, PHP, Python, and Ruby.

• This ability to use Selenium-RC with a high-level programming language to develop test cases also allows the automated testing to be integrated with a project’s automated build environment.

seleniumonlinetraining.info

Page 8: Selenium (1)

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.

Page 9: Selenium (1)

Steps to start with Selenium!

1) Begin: write and run tests in Firefox.Selenium IDE is a Firefox add-on that records clicks, typing, and other actions to make a test, which you can play back in the browser.

2) Customize: your language, your browser.Selenium Remote Control (RC) runs your tests in multiple browsers and platforms. Tweak your tests in your preferred language.

3) Deploy: scale out, speed upSelenium Grid extends Selenium RC to distribute your tests across multiple servers, saving you time by running tests in parallel. seleniumonlinetraining.info

Page 10: Selenium (1)

Browser Selenium-IDE Selenium-RC Operating Systems

Firefox 3 1.0 Beta-1 & 1.0 Beta-2: Record and playback tests Start browser, run tests Windows, Linux, Mac

Firefox 2 1.0 Beta-1: Record and playback tests Start browser, run tests Windows, Linux, Mac

IE 8 Under development Windows

IE 7 Test execution only via Selenium-RC Start browser, run tests Windows

Safari 3 Test execution only via Selenium-RC Start browser, run tests Mac

Safari 2 Test execution only via Selenium-RC Start browser, run tests Mac

Opera 9 Test execution only via Selenium-RC Start browser, run tests Windows, Linux, Mac

Opera 8 Test execution only via Selenium-RC Start browser, run tests Windows, Linux, Mac

Google Chrome Test execution only via Selenium-RC(Windows) Start browser, run tests Windows

Others Test execution only via Selenium-RC Partial support possible As applicable

Supported Browsers* Tests developed on Firefox via Selenium-IDE can be executed on any other supported browser via a simple Selenium-RC command line.

seleniumonlinetraining.info

Page 11: Selenium (1)

Selenium Commands – Selenese1) Actions are commands that generally manipulate the state of

the application. They do things like “click this link” and “select that option”.

• Can be called with “AndWait” suffix, e.g. “clickAndWait”.

2) Accessors examine the state of the application and store the results in variables, e.g. “storeTitle”.

• They are also used to automatically generate Assertions.

3) Assertions are like Accessors, but verify that the state of the application conforms to what is expected. Eg. “make sure the page title is X”, “verify that this checkbox is checked”.

• All Selenium Assertions can be used in 3 modes: “assert”, “verify”, and ” waitFor”. For example, you can “assertText”, “verifyText” and “waitForText”.

seleniumonlinetraining.info

Page 12: Selenium (1)

Selenium IDE

The list ofactions in theactual test caseto execute

The root of web application youwant to test

The log of theevents that wereexecuted, includingany errors orwarning that mayhave occurred

Page 13: Selenium (1)

Selenium IDE

ExecutionCommands

Record testactions

Try the test inthe Web basedTestRunner

Specify commands,including asserts

Reference of thecurrently selectedcommand

seleniumonlinetraining.info

Page 14: Selenium (1)

Test SuiteExecutionControl

Test Cases

Steps of thetest case

Applicationbeing tested

Page 15: Selenium (1)

TestRunner Control

www.Seleniumonlinetraining.info

Page 16: Selenium (1)

TestRunner Control Pause/PlayExecution

Step throughExecution

Control Speedof Execution

Summary ofthe Test

View the log ofthe currentexecution

View the DOMof the currentPage being tested

HighlightElements in theExecution

Run All Tests

Run Selected Test

www.Seleniumonlinetraining.info

Page 17: Selenium (1)

Test Creation Demo in http://test.roosterit.com/

www.Seleniumonlinetraining.info

Page 18: Selenium (1)

Login to http://test.roosterit.com/ Click on Tools || Selenium IDE

www.Swww.Sewww.Seleniumonlinetraining.info

leniumonlinetraining.infoeleniumonlinetraining.info

ss

Page 19: Selenium (1)

Selenium IDE in recording Mode

www.Seleniumonlinetraining.infoWseleniumonlinetraining.infoww.S

eleniumonlinetraining.info

Page 20: Selenium (1)

Add Consultant Details

Page 21: Selenium (1)

Click On Submit

wwsssw.Seleniumonlinetraining.info

www.Seleniumonlinetraining.info

Page 22: Selenium (1)

Inserted Successfully

Page 23: Selenium (1)

Selenium IDE records the Test Steps

Stop Recording

sss

Page 24: Selenium (1)

Save Test Case/Test Suite

ss

Page 25: Selenium (1)

Make the required changes to the Test Case

change Click to clickAndWait command

s

Page 26: Selenium (1)

Make the required changes to the Test Case – change the email id in the second parameter

Make other changes

s

Page 27: Selenium (1)

Second Test Case:searchConsultant

1) Record2) Stop Recording3) Save with a Name4) Make Required

Changes to parameters or Commands

5) Play

Page 28: Selenium (1)

Run the entire Test Suite/Each Test CaseSee RESULT Here

Page 29: Selenium (1)

Test Suite on Firefox

www.Seleniumonlinetrasselenium-ssssssssining.info

Page 30: Selenium (1)

addConsultant Test Case

Page 31: Selenium (1)

Changes made toaddConsultant Test Case

Page 32: Selenium (1)

searchConsultant Test Case

www.Seleniumonlinetraining.info

Page 33: Selenium (1)

Test Case Saved in HTML Tabular Format

www.Swww.Seleniumonlinetraining.info

eleniumonlinetraining.infowww.Seleniumonlinetraining.info

v

Page 34: Selenium (1)

Creating a Test Suite

A Test Suite in Selenium is just an HTML file that contains a table of links to tests

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>

<meta content="text/html; charset=UTF-8" http-equiv="content-type" /> <title>Test Suite</title>

</head><body>

<table id="suiteTable" cellpadding="1" cellspacing="1" border="1" class="selenium">

<tbody><tr><td><b>Test Suite</b></td></tr><tr><td><a href="addConsultant.html">addConsultant</a></td></tr><tr><td><a href="searchConsultant">searchConsultant</a></td></tr></tbody>

</table></body></html>

www.Seleniumonlinetraining.info

Page 35: Selenium (1)

TestRunner Demo

Execute Tests created inside the Firefox TestRunner.

www.Seleniumonlinetraining.info

Page 36: Selenium (1)

addConsultant TestRunner Mode

www.Seleniumonlinetraining.info

Page 37: Selenium (1)

searchConsultant in Execution Mode - TestRunner

www.Seleniumonlinetraining.info

Page 38: Selenium (1)

Questions?

www.Seleniumonlinetraining.info