selenium- a software testing tool

44
SELENIUM AN AUTOMATION TESTING TOOL

Upload: zeba-tahseen

Post on 17-Aug-2015

133 views

Category:

Software


1 download

TRANSCRIPT

SELENIUMAN

AUTOMATION TESTING

TOOL

Brief History of The Selenium Project

• Selenium first came to life in 2004 when Jason Huggins was testing an internal application at ThoughtWorks Originally named JavaScript Functional Tester [JSFT]

• He developed a Javascript library that could drive interactions with the page, allowing him to automatically rerun tests against multiple browsers

• While Selenium was a tremendous tool, it wasn’t without its drawbacks, because of its Javascript based automation engine and the security limitations browsers apply to Javascript, different things became impossible to do

Manual Testing !

I am gonna

automate tests!

• In 2006 a plucky engineer at Google named Simon Stewart started work on a project he called WebDriver

• Simon wanted a testing tool that spoke directly to the browser using the ‘native’ method for the browser and operating system, thus avoiding the restrictions of a sandboxed Javascript environment

• The WebDriver project began with the aim to solve the Selenium’ pain-points

• In 2008 Selenium and WebDriver were merged

I am gonna find a way !

• “Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”

• ~Simon Stewart

Introducing Selenium

• Selenium is a set of different software tools each with a different approach to supporting test automation

• The entire suite of tools results in a rich set of testing functions specifically geared to the needs of testing of web applications of all types

• These operations are highly flexible, allowing many options for locating UI elements and comparing expected test results against actual application behavior

• One of Selenium’s key features is the support for executing one’s tests on multiple browser platforms

SELENIUM TOOL SUITE

• Selenium IDE

• Selenium RC or Remote Control

• Selenium Grid

• Selenium2

Selenium is composed of multiple software tools. Each has a specific role

• Selenium 2 (Selenium Webdriver): • This brand new automation tool provides all sorts of awesome

features, including a more cohesive and object oriented API as well as an answer to the limitations of the old implementation

• It supports the WebDriver API and underlying technology, along with the Selenium 1 technology underneath the WebDriver API for maximum flexibility in porting your tests

• In addition, Selenium 2 still runs Selenium 1’s Selenium RC interface for backwards compatibility

• Selenium 1 (Selenium RC or Remote Control): • Selenium RC was the main Selenium project for a long time,

before the WebDriver/Selenium merge brought up Selenium 2, the newest and more powerful tool

• Selenium-Grid :• It allows the Selenium RC solution to scale for large test suites

and for test suites that must be run in multiple environments• Selenium Grid allows you to run your tests in parallel, that is,

different tests can be run at the same time on different remote machines

• This has two advantages. First, if you have a large test suite, or a slow-running test suite, you can boost its performance substantially by using Selenium Grid to divide your test suite to run different tests at the same time using those different machines

• Also, if you must run your test suite on multiple environments you can have different remote machines supporting and running your tests in them at the same time

• In each case Selenium Grid greatly improves the time it takes to run your suite by making use of parallel processing

• Selenium IDE(Integrated Development Environment) is a prototyping tool for building test scripts also known as record and replay!

• It is a Firefox plugin and provides an easy-to-use interface for developing automated tests

SELENIUM IDE

Selenium IDE Selenium IDE (SIDE) is a complete Integrated Development

Environment (IDE) for building Selenium test case.

Firefox add-on that makes it easy to record, edit, and debug tests.

Provides an easy-to-use interface for developing and running individual test cases or entire test suites.

Can be used to generate code to run the tests with Selenium Remote Control (RC).

11

Step 1: Is Selenium IDE Installed?

Open the Firefox browser window (*1) Go to Tools Check whether Selenium IDE already exist

there (*2) If you see “Selenium IDE” then you already having

Selenium IDE plug-in installed in Firefox browser. If not installed then follow the instruction on the next slide

12

*1Check whether Selenium IDE is already installed

*2

Step 1a: Installing Selenium IDE

13

Or you can find Selenium IDE downloads in Previous Releases directory:

1. Previous Releases

2. Selenium IDE

3. Version 1.0.10

Step 1a: Installing Selenium IDE

In the Firefox browser go to Tools and verify whether “Selenium IDE” is displayed.

Congratulation!

Selenium IDE installation is completed.

14

Selenium IDE is successfully installed

15

RECORDING AND RUNNING

SELENIUM TESTS

Test Case #1: Login

Test-Case Objective:

Ensure Valid User Login

Expected Result:

1. OrangeHRM index page is loaded

2. Correct username is displayed as part of the greeting.

“Welcome Admin” 16

Steps :1. In the login textbox

type “admin”. 2. In the password

textbox type “password”.

3. Click “Submit” button

4. Verify that a correct user name is displayed

5. Log out

Test Script #1: Login

Test Script Steps:

Open OrangeHRM application in Firefox

http://hrm.portnov.com

Login using :

Login Name: admin

Password: password

Click Login button

Highlight “Welcome Admin” text

Right-click and select VerifyTextPresent

Click logout link

17

Recording An Automated Test

1. Open OrangeHRM application in Firefox

http://hrm.portnov.com (*1)

2. Open Selenium IDE in Firefox

Go to Tools Selenium IDE (*2)

18

*2*1

The Record button is ON by

default

Login Test

Make sure Record button is ON!Go to the Browser windowLogin using (*2):

Login Name: admin

Password: passwordClick Login button

19

*1

*2

The Record button is ON by default

Login Name: adminPassword: passwordThen click Login button

Login Test

Highlight “Welcome Admin” text (*1)Right-click and select VerifyTextPresent (*2)Click logout link

20

*1

*2

Highlight “Welcome demo”

Select VerifyTextPresent

Stop Recording

Go to Selenium IDE

Click the red button to STOP recording

All your actions are recorded and displayed sequentially under Command Table Tab

21

Click here to Stop recording

What did we accomplish?

Manual Test-Case

Test-Case Objective Ensure Valid User Login

Steps In the login textbox type

admin. In the password textbox

type password. Click Submit button Verify that a correct user

name is displayed LogoutExpected Result1) OrangeHRM index page is

loaded2) Correct username is

displayed as part of the greeting.“Welcome Admin”

Automated Test-Case 22

We created our first automated test scriptWe created our first automated test script

Running Selenium Automated Test

Make sure the Firefox browser is still open

Go to Selenium IDE and click “Play current test case” button

23

*1 *2

Click to play the Test Case

Make the test case playback in slow mode

Debugging

Examine the result of the script.

24

Time is needed to validate the login information…

The test must WAIT for the next web page to load before proceeding.

What went wrong?

Debugging Tips

Open Selenium IDE through Tools menu, otherwise the IDE may freeze and act unpredictably.

Make sure you substitute click command with clickAndWait command wherever needed.

25

Editing

Editing to add wait time to the script

1. Click the 3rd to last row where ClickA command is located

2. Modify the command field Replace “click” with “clickAndWait”

command

3. Re-play the test…

26

Click this row

Select clickAndWait command

Helpful Notes:

One Firefox browser window must be open.

Multiple browser windows will confuse Selenium.

Play back every automated test to ensure

expected behavior.

Keep playback in slow mode when debugging.

Placing Browser window and Selenium IDE

windows side by side is a convenient way of

tracking test execution step by step.

27

Pros:• Very easy to use• Test case can be recorded once easily and can

be run any number of times• Test case can be exported in any language

Cons:• Supports only Firefox Browser• Does not support advanced versions of any

browser

PROS AND CONS OF SELENIUM IDE

SELENIUM 2 OR

SELENIUM WEB DRIVER

SUPPORTED OPERATING SYSTEMS

• Windows• Linux• Solaris• OS X• Android (with Selendroid or appium)• iOS (with ios-driver or appium)

SUPPORTED WEB BROWSERS

• Google Chrome• Internet Explorer 6, 7, 8, 9, 10 - 32 and 64-bit where

applicable• Firefox: latest ESR, previous ESR, current release,

one previous release• Safari• Opera• HtmlUnit• phantomjs

SUPPORTED PROGRAMMING LANGUAGES

• Java

• C#

• Ruby

• Python

• PHP

• Perl

DOWNLOADING AND

CONFIGURINGSELENIUM 2

OUTPUT

Why migrate to selenium2 from ide or rc?

• Selenium2 supports almost all operating system- Windows, Linux, OS X, Solaris unlike IDE

• Selenium2 supports almost all web browsers- IE, Firefox , Chrome, Opera, Safari unlike IDE

• Selenium2 supports all major languages- Java, C#, Ruby, Python, Perl, PHP unlike IDE

• Selenium doesn’t need to start and stop server at the start and end of the process unlike RC

• Selenium2 supports rich API’s for the advanced versions of web browsers unlike rc and ide

• Selenium2 also supports Android and IOS platforms unlike rc and ide

• Selenium2 can perform mouse movements using web driver unlike Rc and IDe

• Selenium2 directly talks to the browser unlike rc and ide