selenium overview
TRANSCRIPT
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
Selenium Origins
» Selenium is a key mineral which protects the body from Mercury toxicity
» Many of Selenium developers knew Mercury tools very well
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
Selenium supports
» Browsers» Firefox» IE» Safari» Opera» Others – Partially supported
» Operating System» Windows» Linux» Solaris
Javascript
» Selenium is written in Javascript
» Javascript is how AJAX applications are written, so Selenium can
test them too
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
Selenium IDE
» Selenium IDE adds a layer of Record / Playback to Selenium
» Is available for Firefox only
Selenium IDE
Selenese Test Case
Command Target Value
open /jobmining/
type queryTitle qa
select ct_category label=Banking
clickAndWait Submit01
clickAndWait link=sqa
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
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"]
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
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
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>
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)
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
Selenium RC
Proxy
Because the commands for Selenium RC are embedded in a script, a proxy is needed to control the browser.
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
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
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.
Selenium Grid
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]
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
Questions???