Selenium Introduction
Devang Mehta
Quality Analyst, ThoughtWorks
© ThoughtWorks, 2006
Agenda
• Introduction to Selenium (12 Min)
– Origin
– Selenium and its Forms
– Selenium Core
– Selenium RC
– Deployment
– Object locators
– Features
– Add Inn's
• Selenium IDE
• Locator tools.
• Demo (10 Min)
• Build Integration (3 Min)
• Q&A (5 Min)
© ThoughtWorks, 2006
Origins
• Selenium core Originated on a ThoughtWorks Time and expense
project
© ThoughtWorks, 2006
Selenium and
its Forms
• Selenium Core
• Selenium RC
• Selenium IDE
• Selenium on Rails
© ThoughtWorks, 2006
Selenium Core
• A acceptance testing tool for web applications
• Tests run directly in the browser
• Selenium is implemented entirely with browser technology
– JavaScript
– DHTML
– Frames
• Works by looking at the DOM
• Selenium deploys its BrowserBot alongside your application
• Selenium uses JavaScript and IFrames to embed the BrowserBot in
your browser
• Works with virtually any JavaScript-enabled browser
• The engine is tweaked to support a wide range of browsers on
Windows, Mac OS X and Linux
© ThoughtWorks, 2006
Selenium RC
• Where the browser is under the control of another process
• Drivers exist for Java, .NET, Python, and Ruby
• The Browser Bot takes instructions from the adjacent process
– However, JavaScript cannot open sockets (Cross-site scripting
issues)
– The Selenese driver continuously requests pages from the driving
process, delivered as plain text
– This is reply/request (rather than request/reply)
© ThoughtWorks, 2006
Deployment
© ThoughtWorks, 2006
Deployment
© ThoughtWorks, 2006
Object Locator
• HTML-ID’s
– Id=LoginButton
• 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
© ThoughtWorks, 2006
Features
• Multi Platform support
– Windows,Linux,Mac
• Multi browser support
– IE, Firefox, Safari, Netscape
• Multiple programming Language support
– C#, Java, Ruby, Python
• Xpath, Htmlid, DOM, Css selector
• Support Ajax
• ProxyInjection Mode
• Experimental Browsers provided to test secured sites
• Easy to use, small learning curve
• Free-Open source
• Matured Community
© ThoughtWorks, 2006
Add Inn's :
Selenium IDE
• FireFox extension
• Not just a recorder
• Easy record and playback
• Intelligent field selection will use
IDs, names, or XPath as needed
• Auto complete for all common
Selenium commands
• Walk through tests
• Debug and set breakpoints
• Save tests as HTML, Ruby scripts,
or any other format
• Support for Selenium
Userextensions.js file
• Option to automatically assert the
title of every page
© ThoughtWorks, 2006
Add Inn's :
Locator Tools
• XPather
https://addons.mozilla.org/extensions/moreinfo.php?id=1192
• XPath Checker
https://addons.mozilla.org/extensions/moreinfo.php?id=1095
• FireBug
https://addons.mozilla.org/en-US/firefox/addon/1843
© ThoughtWorks, 2006
Demo
© ThoughtWorks, 2006
Build Integration
Test
Test
Suite
Suite
Developer
Report
Cruise Control
• Minimizes integration risk.
• Supports easier defect diagnosis.
• Encourages good testing habit
• Support release management
Build-
Repository Build-
Repository
File
File
Integrates source code and runs tests after each commit of code to the source
repository.
© ThoughtWorks, 2006
Q & A
© ThoughtWorks, 2006
Selenium download
@
http://www.openqa.com/Selenium
http://openqa.org/selenium-rc/
Email: dmehta@thoughtworks.com
© ThoughtWorks, 2006