selenium date:06/10/2009. may 13, 2009 2 agenda testing – test automation selenium –...

55
Selenium Date:06/10/2009

Upload: cornelia-barker

Post on 18-Jan-2018

224 views

Category:

Documents


0 download

DESCRIPTION

May 13, Testing: Test Automation Test automation is a process of writing a computer program to do testing that would otherwise need to be done manually Alternative to the tedious manual testing Overcomes the defects of manual testing Cost effective method Two approaches of test automation – Code Driven Testing – Graphical User Interface (GUI) Testing

TRANSCRIPT

Page 1: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

Selenium

Date:06/10/2009

Page 2: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 20092

Agenda• Testing

– Test Automation• Selenium

– Introduction– Features– Supported platforms

• Selenium Commands– Selenese– Script syntax

• Selenium Components– Selenium IDE– Selenium RC– Selenium Grid– Selenium Core

• Selenium IDE– Building test cases– Running test cases– Converting to other languages– Editing test cases and running with Selenium RC

• Selenium RC– Running HTML test suite

Page 3: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 20093

Testing: Test Automation• Test automation is a process of writing a computer program to do testing that would

otherwise need to be done manually

• Alternative to the tedious manual testing

• Overcomes the defects of manual testing

• Cost effective method

• Two approaches of test automation

– Code Driven Testing

– Graphical User Interface (GUI) Testing

Page 4: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 20094

Testing: Test Automation contd...

• Test automation supports:

– Frequent regression testing

– Rapid feedback to developers during the development process

– Virtually unlimited iterations of test case execution

– Customized reporting of application defects

– Support for Agile and eXtreme development methodologies

– Disciplined documentation of test casesCustomized reporting of application

defects

– Finding defects missed by manual testing

Page 5: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 20095

Selenium: Introduction• Selenium is one of the most powerful open source automation tools for web

application testing

• Primarily developed in Java Script and browser technologies such as DHTML and

Frames and hence supports all the major browsers on all the platforms.

• In terms of coverage for platform and browser, Selenium is probably one of the best

tool available in the market for web applications

• User can customize the selenium tool based on their requirement (code is available

for the user).

Page 6: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 20096

Selenium: Introduction contd...

• Highly flexible

• Highly extensible

• Selenium Components

– Selenium-IDE

– Selenium-Remote Control (RC)

– Selenium-Grid

– Selenium Core

Page 7: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 20097

Selenium: Features• Open Source tool for Web applications

• Tests Browser Compatibility and system functionality

• No licensing cost associated with it

• Customize according to our requirements

• Easy to use:

– a) Test Cases are written in pure HTML

– b) Clean and Impressive User Interface

• Selenium supports multi platform and multi browser in terms of coverage.

Page 8: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 20098

Selenium: Supported Platforms• Windows:

– Internet Explorer 6.0+

– Firefox 0.8 to 2

– Seamonkey 1.0

– Opera 8

• Mac OS X:

– Safari 1.3+

– Firefox 0.8 to 1.5

– Seamonkey 1.0

• Linux:

– Firefox

– Konqueror

Page 9: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 20099

Selenium Commands: Selenese• Selenium provides a rich set of commands for fully testing the web-application in

virtually any way.

• The command set is often called selenese.

• These commands essentially create a testing language.

• A command tells selenium what exactly to do.

• There are three types of Selenium commands

– Actions

– Accessors

– Assertions

Page 10: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200910

Selenium Commands: Selenese contd...

• The selenese commands can test:

– existence of UI elements based on their HTML tags

– test for specific content

– test for broken links, input fields, selection list options, submitting forms,

and table data among other things

– window size, mouse position, alerts

– Ajax functionality

– pop up windows and event handling

Page 11: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200911

Selenium Commands: Selenese contd...

• Actions– Selenium Actions represent something a user would do

– Commands that generally manipulate the state of the application

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

– If an Action fails, or has an error, the execution of the current test is

stopped.

– Many Actions can be called with the “AndWait” suffix, e.g. “clickAndWait”.

– This command makes the browser to wait till the page loads

Page 12: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200912

Selenium Commands: Selenese contd...

• Accessors:– Examine the state of application and store the results in variables

– Any of the selenium accessors can be used to store value

– Internally Selenium uses a map called storedVars keyed to the variable

names.

– They are also used to automatically generate Assertions

– E.g. Use ${intAmount} to put the value stored in intAmount

– Some of the key accessors are

• storeText, storeValue, storeCookie, storeAlert and storeEval

Page 13: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200913

Selenium Commands: Selenese contd...

• Assertions:– Allows user to verify state of the application

– All Selenium Assertions can be used in 3 modes

• Assert – Upon failure test is aborted

• Verify – Upon failure error is logged and test continues

• WaitFor – Waits for a conditions truth lines for given timeout

– Assertions are like Accessors, but they verify that the state of the

application conforms to what is expected

• E.g. “make sure the page title is X” and “verify that this checkbox

is checked”

Page 14: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200914

Selenium Commands: Script Syntax

• Selenium Commands consist of the command and two parameters. For eg:– verifyText //div//a[2] Login

• The parameters are not always required. It depends on the command

• In some cases both parameters are required, in others one parameter is required,

and still in others the command may take no parameters at all. For eg.:

– goBackAndWait command requires no parameter

• GoBackAndWait

– verifyTextPresent command requires only one parameter

• verifyTextPresent Welcome to My Home Page

– type command requires both the parameters

• type id=phone (555) 666-7066

Page 15: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200915

Selenium Commands: Script Syntax contd...

• Commonly used Selenium Commands

– click/clickAndWait

• performs a click operation, and waits for a new page to load

– verifyTitle/assertTitle

• verifies an expected page title

– verifyTextPresent

• verifies expected text is somewhere on the page

– waitForPageToLoad

• pauses execution until an expected new page loads. Called

automatically when clickAndWait is used

Page 16: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200916

Selenium Components• There are four variants or components of Selenium

• They can be used in isolation or in combination to create complete automation suite

for the web applications.

• These components are

– Selenium IDE

– Selenium Remote Control (RC)

– Selenium Grid

– Selenium Core

Page 17: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200917

Selenium Components: Selenium IDE• Selenium IDE is a Firefox plug in, which includes the entire Selenium Core, allows

to record, play back, edit, and debug tests in browser

• Selenium IDE is the only flavor of Selenium which allows to record user actions on

browser window

• It can also record user actions in most of the popular languages like Java, C#, Perl,

Ruby etc. This eliminates the need of learning new vendor scripting language.

• Selenium default scripts are html (added JavaScript)

Page 18: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200918

Selenium Components: Selenium IDE contd...

• Selenium IDE – Installation

– The installation is very

simple.

– It comes as the firefox plug

in and it directly gets

installed at the time of

downloading itself,

provided that firefox is

installed

– After installation it can be

started directly from firefox

Tools menu

Page 19: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200919

Selenium Components: Selenium IDE contd...

Page 20: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200920

Selenium Components: Selenium IDE contd...

• Selenium IDE contains toolbar including various buttons which are helpful in

recording and running the tests

• Speed Control controls how fast the test case runs

• Run All runs the entire test suite when a test suite with multiple test cases is loaded

• Run runs the currently selected test

• Pause/Resume allows stopping and re-starting of a running test case

• Step allows one to “step” through a test case by running it one command at a time

• Record records the user's browser action

Page 21: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200921

Selenium Components: Selenium IDE contd...

• TestRunner Mode allows to run the test case in a browser loaded with the

Selenium-Core TestRunner. The TestRunner is not commonly used now and is

likely to be deprecated.

• Test case pane displays the script. It has two tabs, one for displaying the command

and their parameters in a readable “table” format.

– Source tab displays the test case in the native format in which the file will

be stored. By default, this is HTML

– The Command, Target, and Value entry fields display the currently

selected command along with its parameters.

Page 22: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200922

Selenium Components: Selenium IDE contd...

• Log/Reference/UI-Element/Rollup Pane is used for four different functions–Log,

Reference, UI-Element, and Rollup–depending on which tab is selected.

– Log tab displays error messages and information messages showing the

progress

– Reference tab will display documentation on the current command.

– The information for UI-Element and Rollup tab can be found in Help menu

of Selenium IDE

Page 23: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200923

Selenium Components: Selenium IDE contd...

Test case pane

Speed Control

Run All

Run

Pause/Resume

Step

Test Runner

Log/Reference/UI-Element/Rollup Pane

Record

Page 24: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200924

Selenium Components: Selenium IDE contd...

• Selenium IDE features

– Easy record and playback

– Debug and set breakpoints

– Conversion of test cases to multiple programming languages

– Option to automatically assert the title of every page

– Support for Selenium user-extensions.js file

– Very useful for beginners to understand the test cases and commands

Page 25: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200925

Selenium Components: Selenium IDE contd...

• Selenium IDE is useful for less technical people, as it supports only simple

programming and not the tests with complex programming functions

• Selenium does not directly support:

– condition statements

– Iteration

– logging and reporting of test results

– database testing

– test case grouping

– test case dependency

Page 26: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200926

Selenium Components: Selenium RC• Selenium Remote Control is a test tool that allows to write automated web

application in any programming language (Java, .NET, Perl, Python, and Ruby,

PHP)

• Selenium-RC is the solution for tests that need more than simple browser actions

and linear execution.

• It uses full power of programming language.

• It overcomes the disadvantages of IDE

• Selenium RC can create more complex tests like reading and writing files, querying

a database, emailing test results.

Page 27: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200927

Selenium Components: Selenium RC contd...

• Although tasks that are not supported by IDE, are not supported by Selenium

directly, all of them can be achieved by using programming techniques with a

language-specific Selenium-RC client library.

• There are two components of Selenium RC, which play an important role in the

running of the test cases.

• The components of Selenium RC are:

– Selenium Server

– Client Libraries

Page 28: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200928

Selenium Components: Selenium RC contd...

• Selenium Server

– Launches and kills browsers

– Interprets and runs the Selenese commands passed from the test program

– Acts as an HTTP proxy, intercepting and verifying HTTP messages passed

between the browser and the AUT.

• Client libraries

– Provide the interface between each programming language and the

Selenium-RC Server.

Page 29: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200929

Selenium Components: Selenium Grid• Selenium Grid allows to run Selenium tests in parallel

• Cuts down the time required for running acceptance tests to a fraction of the total

time it currently takes

• Selenium Grid runs on top of Selenium Remote Control

• It is primarily used in case of large test suites or the test suites that need to be run in

multiple environment

• To run Selenium Grid, Ant 1.7+ needs to be installed on the system.

Page 30: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200930

Selenium Components: Selenium Core• Selenium Core is a Test Tool for web applications

• Selenium core tests runs directly in a Browser

• Written in Pure JavaScript and DHTML

• Selenium RC server uses Selenium Core while sending the requests to the browser

• Selenium Core interprets and executes Selenese commands using the browser’s

built-in JavaScript interpreter

Page 31: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200931

Selenium IDE: Building Test Cases• There are three methods which are used in order to build the test cases.

• The developer, while building the test cases with Selenium IDE, requires all the

three methods frequently.

• These methods are

– Recording

– Adding Verifications and Asserts With the Context Menu

– Editing

Page 32: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200932

Selenium IDE: Building Test Cases contd...

• Recording

– This method records the user actions with the application under test.

– To record the tests, start selenium IDE.

– The record button on Selenium IDE toolbar is ON by default.

– During recording, Selenium-IDE will automatically insert commands into the

test case based on actions including,

• clicking a link

• entering values

• selecting options from a drop-down listbox

• clicking checkboxes or radio buttons

Page 33: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200933

Selenium IDE: Building Test Cases contd...

• Adding Verifications and Asserts With the Context Menu

– In order to do this, with Selenium-IDE recording, open the web page

– Select some text and right click on the selected text

– A context menu showing verify and/or assert commands gets displayed

– Also, the Show All Available Commands menu option also gets displayed

– This shows many, many more commands, again, along with suggested

parameters, for testing currently selected UI element

Page 34: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200934

Selenium IDE: Building Test Cases contd...• Editing

– Editing commands include inserting a new command or comment and

editing the existing command or comment in the table view or source view

– Insert Command

• To insert a command in table view, select the point in the test case

where the command has to be inserted. Right-click and select Insert

Command. Now use the command editing text fields to enter the new

command and its parameters.

• To insert a command in source view, select the point in the test case

where the command has to be inserted, and enter the HTML tags

needed to create a 3-column row containing the Command. Be sure to

save the test before switching back to Table view.

Page 35: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200935

Selenium IDE: Building Test Cases contd...

– Insert Comment

• To insert a comment in the table view, select the point in the test

case where the comment has to be inserted. Right-click and select

Insert Comment. Now use the Command field to enter the

comment. The comment appears in purple font

• To insert a comment in the source view, select the point in the test

case where the comment has to be inserted. Add an HTML-style

comment, i.e., <!– comment here –>

Page 36: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200936

Selenium IDE: Building Test Cases contd...

• Edit a Command or Comment

– To edit an existing command or comment in table view, simply select the

line to be changed and edit it using the Command, Target, and Value fields

– To edit an existing command or comment in source view, simply modify

which line wished–command, parameter, or comment , since source view

provides the equivalent of a WYSIWYG editor

• The File=>Open, Save and Save As menu commands behave similarly to opening

and saving files in most other programs. When an existing test case is opened,

Selenium-IDE displays its Selenium commands in the test case pane.

Page 37: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200937

Selenium IDE: Running Test Cases• IDE allows many options to run the test cases. With IDE, lot of things are possible.

For instance, running the whole test case, starting and stopping it, running it one

line at a time, and a batch run of entire test suite.

• Execution of test cases is very flexible

• Run a Test Case

– Click the Run button to run the currently displayed test case

• Run a Test Suite

– Click the Run All button to run all the test cases in the currently loaded test

suite

Page 38: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200938

Selenium IDE: Running Test Cases contd...

• Stop and Start

– The Pause button can be used to stop the test case while it is running. The

icon of this button then changes to indicate the Resume button. To

continue click Resume

• Stop in the Middle

– A breakpoint can be set in the test case to cause it to stop on a particular

command. This is useful for debugging the test case. To set a breakpoint,

select a command, right-click, and from the context menu select Toggle

Breakpoint

Page 39: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200939

Selenium IDE: Running Test Cases contd...

• Start from the Middle

– The IDE can be told to begin running from a specific command in the

middle of the test case. This also is used for debugging. To set a start-

point, select a command, right-click, and from the context menu select

Set/Clear Start Point

• Run Any Single Command

– Double-click any single command to run it by itself. This is useful when

writing a single command. This is very useful on having a doubt while

writing the command

Page 40: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200940

Selenium IDE: Running Test Cases contd...

• Using Base URL

– The base URL field at the top of IDE is very useful in running the test cases

in different domains

– This is useful when the site has some in-house beta site.

– Any test cases for a those particular sites that begin with an open

statement should specify a relative URL as the argument to open rather

than an absolute URL (one starting with a protocol such as http: or https:).

Page 41: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200941

Selenium IDE: Running Test Cases contd...

• For eg:

– The test case is running against -

http://news.portal.com/about.html

– This same test case with a

modified Base URL setting would

be run against

http://beta.news.portal.com/about.html

Page 42: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200942

Selenium IDE: Converting to other language• One of the best feature of Selenium IDE is that it can convert the recorded test

cases to different languages, such as Java, Ruby, Python, C# etc.

• With this conversion, the test cases can be run with selenium RC with the help of

the language specific client libraries

• To convert the recorded test cases, Go to Options menu and click Format.

• On clicking Format a drop-down appears. Select the preferred language and the test

cases get converted to the selected language.

Page 43: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200943

Selenium IDE: Converting to other language contd...

• The converted test cases appear in

the Source tab of Test pane.

• Selenium IDE cannot run these

converted test cases

Page 44: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200944

Selenium IDE: Converting to other language contd...

• These tests does not contain any programming logic such as conditions, testing

database etc.

• These test cases can be executed with the help of the client libraries available for

respective language in Selenium RC

• Optionally, test engine platform like Nunit and TestNG be adopted

• TestNG and Junit are the test engines very commonly used for Java

• Some development environments like eclipse has direct support for these test

engines via plugin

Page 45: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200945

Selenium IDE: Editing test cases and running with Selenium RC

• As discussed, Selenium IDE can record the test cases and can convert them to any

of the languages of Java, Ruby, Python, Perl, C#, .Net etc

• To run these test cases, Selenium RC is used, as Selenium IDE can not run the test

cases apart from those written in HTML

• Selenium RC uses language specific client drivers to run these test cases. For

example, for running test cases in Java Selenium RC has Selenium-Java-client-

driver

Page 46: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200946

Selenium IDE: Editing test cases and running with Selenium RC contd...• In order to run the test cases with Selenium RC, they have to be saved with

respective extensions. For example, in order to run the test case that is converted to

Java from Selenium IDE, it has to saved with extension .java

• Selenium RC, with the help of language specific client drivers, executes the test

cases from different languages.

• The test cases that are exported from Selenium IDE may not be run directly with

Selenium IDE. These test cases may require some editing in order to run them with

Selenium RC.

Page 47: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200947

Selenium IDE: Editing test cases and running with Selenium RC contd...

• The editing of the test cases, depend on the language the test case is converted in.

• For example, in order to run the test cases in Java, the class containing main

method should be added.

• Likewise few lines of code may need to be added in the test cases, depending on

the language

• Here are the sample main class that completes the test case and makes it ready to

run as a Java test case using Java client driver.

public static Test Suite(){return new TestSuite(Classname.class);}public static void main(String args[]){junit.textui.TestRunner.run(Suite());}}

Page 48: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200948

Selenium RC: Running HTML test suite • The Selenium RC server comes as an executable jar file

• This executable jar file comes with all the language specific client libraries

• Running the jar file allows to run the various test suites designed in the various

languages with the help of the client libraries of respective languages

• The selenium RC can be downloaded from

– http://seleniumhq.org/download/

Page 49: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200949

Selenium RC: Running HTML test suite contd...

• Selenium IDE records the user actions and stores these user actions in the source

tab of the test pane.

• The user actions are recorded and the test cases that are stored by selenium IDE

are primarily stored in HTML.

• These HTML test cases can also be run with Selenium RC

• To run the test cases with Selenium RC, the test cases should be copied to some

file with .html extension say Test.html

• Selenium RC cannot run test cases directly

Page 50: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200950

Selenium RC: Running HTML test suite contd...

• To run the test cases with Selenium RC, these test cases should be embedded in a

test suite say Suite.html

• The suite can contain one or more test cases

• In order to run the HTML test suite, the Selenium RC server should be run.

• After downloading Selenium RC, extract it in some directory

• After extracting Selenium RC go to the Selenium RC Server folder where the

executable jar - selenium-server.jar

• To run the jar, the system must contain Java jre version 1.4 or above.

Page 51: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200951

Selenium RC: Running HTML test suite contd...

• The results of the execution of test gets store in some HTML file say results.html

• To run the HTML test suite with Selenium RC, type the command

– java -jar selenium-server.jar -htmlsuite *iexplore http://www.google.co.in

/path/to/suite.html /path/to/results.html

• This command runs all the test cases mentioned in suite.html and stores the results

in results.html

Page 52: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200952

Selenium: Disadvantages• The Selenium remote control is quite slow at driving the browser

• It is possible to run only a limited number of concurrent tests on the same remote

control server

• Selenium RC has a limitation in running tests in parallel

• If selenium fails to recognize objects, it cannot be assured of any add-ins which

would be required

• Also Support provided for Selenium would be very less ( like in case of QTP, HP

provides standard solutions and supports to issues)

Page 53: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200953

Selenium: License• All Selenium projects are licensed under the Apache 2.0 License.

• Apache license allows developer to contribute to the code

• This license also allows contributor to choose to distribute the Program in object

code form under its own license agreement, with conditions.

• The complete license for Selenium can be found here:

– http://www.apache.org/licenses/LICENSE-2.0

Page 54: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

May 13, 200954

References• http://seleniumhq.org/

• Selenium Forums

– http://clearspace.openqa.org/community/selenium

– http://www.sqaforums.com/

• Selenium Commercial Support

– http://thoughtworks.com/

Page 55: Selenium Date:06/10/2009. May 13, 2009 2 Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –

Thank You !