1. Lets Automate!
Lets Automate your web tests using Selenium
A guide to automation using selenium
Ahmed Mubbashir Khan, http://about.me/mubbashir
@mubbashir
2. Agenda
Demo of sikuli-on-selenium
Automation
Automation objective
What is selenium
-Components of selenium
-Walkthrough
- S-IDE
- Driver/RC
-Grid
-Walking through the code of the demo(Maven, Java, TestNG)
Command Reference
- Locators Reference
3. Test automation is any use of tools to aid
testing- James Bach (http://www.satisfice.com/blog/archives/118)
OK- But its a very broad term, what are we
going to automate?
Answer: Regression Tests (Checks to be
precise)
http://www.developsense.com/blog/2009/08/testing-vs-checking/
What is Test/Check Automation?
4. Expecting automation to find lots of bugs when
you are automating regression testing is the
wrong objective - Dorothy Graham (STAReast 19 April, 2012)
Automation is not a magic tool. It will not find
bugs - good tests finds the bugs - Dorothy
Graham (STAReast 19 April, 2012)
What is the objective of (Regression)
Automation?
5. Think of your automation as a baseline test
suite to be used in conjunction with manual
testing, rather than as a replacement for it-
James Bach (http://www.satisfice.com/articles/test_automation_snake_oil.pdf (1999))
Just as there can be quality
software, there can be quality test automation-
James Bach (http://www.satisfice.com/articles/test_automation_snake_oil.pdf (1999))
What is the objective of (Regression)
Automation??
6. Test Automation is a software Project, Treat it
as a software project.
Test Automation is coding, why would you ask
it to be done by someone who can't code-
Adam Goucher
Automation is Software.
7. • Rapid feedback to developers
• Virtually unlimited iterations of test case
execution
• Support for Agile and extreme development
methodologies
• Disciplined documentation of test cases
• Customized defect reporting
• Finding defects missed by manual testing
Why Not Automate? Which are Myths? and
what about ROI?
To Automate or Not to Automate?
9. Selenium (set of libraries) automates browsers.
That's it. What you do with that power is entirely
up to you. (http://seleniumhq.org/)
Selenium's History...
What is selenium?
10. Its Opensource (code.google.com/p/selenium/)
It runs in many browsers and operating
systems
Can be controlled by many programming
languages and testing frameworks.
Companies using selenium includes Google,
BBC, Ubuntu, Pivotal Labs, Mozlilla and Yelp
among many others.
And "Die QTP Die" http://paulhammant.
Why selenium?
12. Selenium does not own the browser, OS does.
Selenium can interact with the rendered HTML content of a
given web page, but it cannot interact with native browser
operations
● Anything which is outside web app (e.g.
upload/download dialog box)
● Anything which runs in a different runtime (e.g flash,
java applets)
● Some HTML5 features (e.g. video, audio, canvas,
webGL)
What selenium can't do?
13. Selenium is not a testing framework.
Selenium allows you to interact with web pages but
creating tests on top of it is the reponsibility of Test
Framework (xUnit) (https://twitter.com/#!
/AutomatedTester/status/176830982316494849)
What selenium can't do?
20. Actions/Commands (http://release.seleniumhq.org/selenium-core/1.0.1/reference.
html#actions)
Element Locators
● identifier=id: Select the element with the specified @id attribute. If no match is found, select the
first element whose @name attribute is id. (This is normally the default; see below.)
● id=id: Select the element with the specified @id attribute.
● name=name: Select the first element with the specified @name attribute.
○ username
○ name=username
● The name may optionally be followed by one or more element-filters, separated from the name
by whitespace. If the filterType is not specified, value is assumed.
○ name=flavour value=chocolate
● dom=javascriptExpression: Find an element by evaluating the specified string. This allows you
to traverse the HTML Document Object Model using JavaScript. Note that you must not return a
value in this string; simply make it the last expression in the block.
○ dom=document.forms['myForm'].myDropdown
○ dom=document.images[56]
○ dom=function foo() { return document.links[1]; }; foo();
IDE- Command Reference-Locators
21. Actions/Commands (http://release.seleniumhq.org/selenium-core/1.0.1/reference.
html#actions)
Element Locators
● xpath=xpathExpression: Locate an element using an XPath expression.
○ xpath=//img[@alt='The image alt text']
○ xpath=//table[@id='table1']//tr[4]/td[2]
○ xpath=//a[contains(@href,'#id1')]/@class
○ xpath=(//table[@class='stylee'])//th[text()='theHeaderText']/../td
○ xpath=//input[@name='name2' and @value='yes']
○ xpath=//*[text()="right"]
● 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. Please refer to CSS2 selectors,
CSS3 selectors for more information..
○ css=a[href="#id3"]
○ css=span#firstChild + span
IDE- Command Reference-Locators
22. Actions/Commands (http://release.seleniumhq.org/selenium-core/1.0.1/reference.
html#actions)
String-match Patterns
● glob:pattern: Match a string against a "glob" (aka "wildmat") pattern. "Glob" is a kind of limited
regular-expression syntax typically used in command-line shells. In a glob pattern, "*" represents
any sequence of characters, and "?" represents any single character. Glob patterns match
against the entire string.
● regexp:regexp: Match a string using a regular-expression. The full power of JavaScript regular-
expressions is available.
● regexpi:regexpi: Match a string using a case-insensitive regular-expression.
● exact:string: Match a string exactly, verbatim, without any of that fancy wildcard stuff.
If no pattern prefix is specified, Selenium assumes that it's a "glob" pattern
IDE- Command Reference- String
match patterns