0
Dov'è il tasto Ok???
Michele Orselli
Who am I
Michele Orselli
– Developer @Ideato
– Email: mo@ideato.it
– 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 view
– Great for QA
• Pros & Cons
• Not a substitute for unit ...
Selenium
Remote Control
– Java Based
– Open Source
IDE
– Firefox 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
Download
– http://selenium.googlecode.com/files/selenium-remote-control-1.0.3.zip
Unzip
Java -jar selenium...
Selenium API
Browser-independent API
– Same test run on several os/browser
Bindings for several languages
Base API:
– Asse...
A first test (Selenese)
open /web/listaeventi.php
assertTextPresen
t
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 attrib...
Finding Elements
String-match Patterns
– glob:pattern:
• "*": any sequence of characters
• "?": any single character.
• Gl...
Finding Elements (2)
Resolving strategies:
– dom, for locators starting with "document."
– xpath, for locators starting wi...
Css Selectors
• all css1, css2 and css3 selectors (except namespaces in
css3)
– css=a[href="#id3"]
– css=span#firstChild +...
Xpath Selectors
Level Separator: /
Every Level: //
Wildcard: *
Attribute: @
Wildcard @*
Examples:
– xpath=//img[@alt='The ...
Demo
Limitation
Test are sloooooooow
– Reuse browser session
– Test are not indipendent
Expressiveness
– Build your own DSL on ...
Beyond Selenium
Get rid of the browser!
– Framework-dependent approaches (eg: symfony)
– Generic, curl-style based
• https...
Demo
We're done!
Q&A
Thank you!
Email: mo@ideato.it
Twitter: _orso_
Please rate my talk!
– http://joind.in/2120
Upcoming SlideShare
Loading in...5
×

Dov'è il tasto ok?

752

Published on

Introduction to functional test with selenium rc, selenium ide and phpunit integration

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
752
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Dov'è il tasto ok?"

  1. 1. Dov'è il tasto Ok??? Michele Orselli
  2. 2. Who am I Michele Orselli – Developer @Ideato – Email: mo@ideato.it – Twitter: _orso_
  3. 3. This site is broken! Credits: http://thedailywtf.com/
  4. 4. This site is broken! Credits: http://thedailywtf.com/
  5. 5. This site is broken! Credits: http://thedailywtf.com/
  6. 6. Testing and You How do you ensure software quality? – Testing? – QA?
  7. 7. Testing Triangle Credits: http://patrickwilsonwelsh.com/?p=32
  8. 8. Functional Tests • Check a feature from the user's point of view – Great for QA • Pros & Cons • Not a substitute for unit test
  9. 9. Selenium Remote Control – Java Based – Open Source IDE – Firefox extension – Record and Playback
  10. 10. Where to use it • Acceptance Test • Bug Report • Performance • Cross-browser compatibility
  11. 11. Selenium RC Architecture Credits: http://seleniumhq.org/
  12. 12. Getting Started Download – http://selenium.googlecode.com/files/selenium-remote-control-1.0.3.zip Unzip Java -jar selenium-server.jar – Options: • port • timeout • log • HtmlSuite • -h show all available options
  13. 13. Selenium API Browser-independent API – Same test run on several os/browser Bindings for several languages Base API: – Assert* – Verify* – WaitFor*
  14. 14. A first test (Selenese) open /web/listaeventi.php assertTextPresen t Faccio cose vedo gente Plain HTML Table: ... ... ...
  15. 15. A first test (PHPUnit)
  16. 16. Where's the OK button? (1)
  17. 17. Where's the Ok button? (2)
  18. 18. Where's the Ok button? (3)
  19. 19. 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
  20. 20. Finding Elements String-match Patterns – glob: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
  21. 21. Finding Elements (2) Resolving strategies: – dom, for locators starting with "document." – xpath, for locators starting with "//" – identifier, otherwise
  22. 22. 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”]
  23. 23. 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')]
  24. 24. Demo
  25. 25. Limitation Test are sloooooooow – Reuse browser session – Test are not indipendent Expressiveness – Build your own DSL on top of selenium
  26. 26. Beyond Selenium Get rid of the browser! – Framework-dependent approaches (eg: symfony) – Generic, curl-style based • https://github.com/enygma/frisk • PHPUnitWebBrowser • everzet.com/behat
  27. 27. Demo
  28. 28. We're done! Q&A
  29. 29. Thank you! Email: mo@ideato.it Twitter: _orso_ Please rate my talk! – http://joind.in/2120
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×