If you can't read please download the document
Upload
michele-orselli
View
1.116
Download
2
Embed Size (px)
Citation preview
wtc10it_slides_template
Dov' il tasto Ok???
Michele Orselli
Who am I
Michele OrselliDeveloper @Ideato
Email: [email protected]
Twitter: _orso_
This site is broken!
Credits: http://thedailywtf.com/
This site is broken!
Credits: http://thedailywtf.com/
This site is broken!
Credits: http://thedailywtf.com/
Testing and You
How do you ensure software quality?Testing?
QA?
Testing Triangle
Credits: http://patrickwilsonwelsh.com/?p=32
Functional Tests
Check a feature from the user's point of viewGreat for QA
Pros & Cons
Not a substitute for unit test
Selenium
Remote ControlJava Based
Open Source
IDEFirefox extension
Record and Playback
Where to use it
Acceptance Test
Bug Report
Performance
Cross-browser compatibility
Selenium RC Architecture
Credits: http://seleniumhq.org/
Getting Started
Downloadhttp://selenium.googlecode.com/files/selenium-remote-control-1.0.3.zip
UnzipJava -jar selenium-server.jarOptions: port
timeout
log
HtmlSuite
-h show all available options
Selenium API
Browser-independent APISame test run on several os/browser
Bindings for several languagesBase API:Assert*
Verify*
WaitFor*
A first test (Selenese)
open
/web/listaeventi.php
assertTextPresent
Faccio cose vedo gente
Plain HTML Table:
...
...
...
A first test (PHPUnit)
Where's the OK button? (1)
Where's the Ok button? (2)
Where's the Ok button? (3)
Finding Elements
Identifing elements: identifier=id: @id/@name
id=id: Select the element with the specified @id attribute.
name=name: Select the first element with the specified @name attribute.
dom=function foo() { return document.links[1]; }; foo();
link=textPattern
http://release.seleniumhq.org/selenium-remote/control/0.9.2/doc/dotnet/Selenium.html
Finding Elements
String-match Patternsglob:pattern: "*": any sequence of characters
"?": any single character.
Glob patterns match against the entire string.
regexp:regexp: match a string using a regular-expression.
exact:string: match a string exactly
Finding Elements (2)
Resolving strategies:dom, for locators starting with "document."
xpath, for locators starting with "//"
identifier, otherwise
Css Selectors
all css1, css2 and css3 selectors (except namespaces in css3)css=a[href="#id3"]
css=span#firstChild + span
pseudo classes :nth-of-type, :nth-last-of-type, :first-of-type, :last-of-type
:visited, :hover, :active, :focus
pseudo elements::first-line,::first-letter, ::selection, ::before, ::after
examples: div#id, div.class, div > p > a
a[href=http://www.google.com]
Xpath Selectors
Level Separator: /Every Level: //Wildcard: *Attribute: @Wildcard @*
Examples:xpath=//img[@alt='The image alt text']
xpath=//table[@id='table1']//tr[4]/td[2]
xpath=//a[contains(@href,'#id1')]
Demo
Limitation
Test are sloooooooowReuse browser session
Test are not indipendent
ExpressivenessBuild your own DSL on top of selenium
Beyond Selenium
Get rid of the browser!Framework-dependent approaches (eg: symfony)
Generic, curl-style basedhttps://github.com/enygma/frisk
PHPUnitWebBrowser
everzet.com/behat
Demo
We're done!
Q&A
Thank you!
Email: [email protected]: _orso_
Please rate my talk!http://joind.in/2120