selenium overview

26
Selenium Overview

Upload: aacharya-rakesh-tiwari

Post on 20-Jan-2016

22 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Selenium Overview

Selenium Overview

Page 2: Selenium Overview

Today's Session Covers

» Selenium Origins

» Selenium – What is it?

» Types of Selenium

» Selenium IDE

» Selenese Test Cases and Test Suites

» Selenium RC

» Selenium Core

» Element Locators

Page 3: Selenium Overview

Selenium Origins

» Selenium is a key mineral which protects the body from Mercury toxicity

» Many of Selenium developers knew Mercury tools very well

Page 4: Selenium Overview

What is Selenium

» Selenium is a web test tool that runs in the browser

» Selenium is implemented completely with Browser technology –

Javascript , DHTML , Frames

» Works with virtually any Javascript-enabled browser

Page 5: Selenium Overview

Selenium supports

» Browsers» Firefox» IE» Safari» Opera» Others – Partially supported

» Operating System» Windows» Linux» Solaris

Page 6: Selenium Overview

Javascript

» Selenium is written in Javascript

» Javascript is how AJAX applications are written, so Selenium can

test them too

Page 7: Selenium Overview

Types of Selenium

» Selenium Core – The main component of Selenium

» Selenium RC – A scripting layer over Selenium Core

» Selenium IDE – a Firefox extension with record / playback

functionality

» Selenium Grid - distribute your tests on multiple machines so that

you can run your tests in parallel

Page 8: Selenium Overview

Selenium IDE

» Selenium IDE adds a layer of Record / Playback to Selenium

» Is available for Firefox only

Page 9: Selenium Overview

Selenium IDE

Page 10: Selenium Overview

Selenese Test Case

Command Target Value

open /jobmining/

type queryTitle qa

select ct_category label=Banking

clickAndWait Submit01

clickAndWait link=sqa

Page 11: Selenium Overview

Checkpoints

Of course, scripts wouldn’t be tests if they didn’t check something» assert* tests fail the test immediately» verify* tests keep track of results and continue the script regardless

verifyTextPresent Job Description dfgdg

asserTextPresent Job Requirements sdrfasf

Page 12: Selenium Overview

Locators

Selenium identifies what a component is through the use of a locator

» link=name» dom=document.images[56]» xpath=//table[@id='table1']//tr[4]/td[2]» css=a[href="#id3"]

Page 13: Selenium Overview

Playback

Playback of a single script is handled through the IDE

» Run – Go as fast as the script can process

» Walk – Slows down the execution

» Step – Executes the next step

Page 14: Selenium Overview

Test Suites

In order to run multiple scripts, you need to chain them together in a Test Suite

» Just another html table

» Runs inside Firefox, but not in S-IDE

» Saved in the same directory as the tests that are included in it

Page 15: Selenium Overview

Test Suites

<table> <tr> <td>Job Search test suite</td> </tr> <tr> <td><a target="testFrame" href=“selenium-ide-01.html">Job

Search</a></td> </tr></table>

Page 16: Selenium Overview

Selenium RC

Selenium IDE is great for quick recording of tests, but it somewhat

lacks for power

Selenium RC gives you the ability to drive Selenium from a real

programming language (Java, Perl, Python, Ruby,C# and PHP)

Page 17: Selenium Overview

Why do you want a real language?

By using Selenium inside a full fledged language you can do the following

» Check the database

» Control external services

» Launch multiple windows

» Run multiple browsers in parallel

Page 18: Selenium Overview

Selenium RC

Page 19: Selenium Overview

Proxy

Because the commands for Selenium RC are embedded in a script, a proxy is needed to control the browser.

Page 20: Selenium Overview

Same Origin

Prevents a document or script loaded from one origin from getting or

setting properties of a document from a different origin – Mozilla

security documentation

In other words, cannot work across server boundaries

Page 21: Selenium Overview

Selenium Core

» Selenium Core is used by both Selenium IDE and RC

» Runs test suites on the same server to avoid the Same Origin

problem

» Don’t have same flexibility as RC, but tests and code under test is

in the same spot

Page 22: Selenium Overview

Selenium Grid

» Selenium Grid allows you to run multiple instances of Selenium

Remote Control in parallel.

» It allows you to easily run multiple tests in parallel, on multiple

machines in an heterogeneous environment. 

Page 23: Selenium Overview

Selenium Grid

Page 24: Selenium Overview

Element Locators

» id=id

Select the element with the specified @id attribute.

» name=name

Select the first element with the specified @name attribute.

» identifier=id

Select the element with the specified @id attribute

If no match is found, select the first element whose @name attribute is id.

» dom=javascriptExpression

Find an element using JavaScript traversal of the HTML Document

Object Model. DOM locators must begin with "document."

dom=document.forms['myForm'].myDropdown

dom=document.images[56]

Page 25: Selenium Overview

Element Locators

» xpath=xpathExpression

Locate an element using an XPath expression. XPath locators must

begin with "//".

xpath=//img[@alt='The image alt text']

xpath=//table[@id='table1']//tr[4]/td[2]

» link=textPattern

Select the link (anchor) element which contains text matching the specified pattern.

link=The link text

» css=cssSelectorSyntax

Select the element using css selectors.

css=a[href="#id3"]

css=span#firstChild + span

Page 26: Selenium Overview

Questions???