SlideShare a Scribd company logo
WebTest Efficient Functional Web Testing with HtmlUnit and Beyond Marc Guillemot JUG Cologne 25.08.2008
Your speaker French developer exiled in Germany Independent consultant since 2002 Focus on Java, Groovy, Grails and ... web testing HtmlUnit & WebTest lead developer Committer to Groovy & NekoHTML Blog:  http://mguillem.wordpress.com Site (coming):  http://www.efficient-webtesting.com
Agenda Introduction to WebTest Test automation: a software engineering activity Extending WebTest Myths and best practices WebTest and AJAX WebTest's future(s) Conclusion Q & A
What I won't say Why you should automate your web application tests How to install WebTest How to integrate into your build Why Selenium sucks ;-)
What is WebTest Automated web functional testing tool Open Source (Apache 2 license) Founded in 2001 Currently 4 committers (Germany, Switzerland, USA, Australia) Built on top of Apache Ant http://webtest.canoo.com
Who uses WebTest? Open Source project => no idea! Let's look at the mailing list: 700 subscribers [email_address] *@apache.org *@*.gov Akamai, AMD, Axa, Bayer, Boeing, BT, Citigroup, Crédit-Suisse, CSC, DHL, EDS, IBM, Lexmark, Novartis, Oracle, Paypal, Sun, T-Mobile, Thalesgroup, Verisign, Zuehlke, ... => everybody from small to huge
demo (on a strange site)
Over 100 WebTest Steps General <invoke .../> <clickLink .../> ... Forms <setInputField .../> <setRadioButton .../> <clickButton .../> ... Verification <verifyTitle .../> <verifyXPath .../> <verifyInputField .../> ... PDF <pdfDecryptDocument .../> <pdfVerifyField .../> ... Excel documents <excelFindRow .../> <excelVerifyCellValue .../> ... Email, Applets, ... Comprehensive online documentation http://webtest.canoo.com
A software engineering activity
Apply rules of software engineering Remove duplications Extract modules Use source control Consider modifications and extensions Ant, Java, Groovy
XPath Learn XPath Learn XPath!!!  Apply it wisely /html/body/div[2]/center/table[3]/tr/td[@id='total'] //*[@id='total'] Write HTML code allowing simple XPath expressions!!!
Apply the right testing paradigm Capture / replay Model based testing Data driven testing Scripted automation
demo WebTestRecorder
Model based testing Specification: modelling expected behavior Be tolerant to accidental behavior Example: bad XPath: /html/body/div[2]/center/table[3] better: //*[@id='total'] Fault model: modelling unexpected behavior < not > < verifyText text= &quot;NullPointerException&quot;/> </ not >
demo data driven
Scripted automation Maximum flexibility and power Maximum responsibility
Extending WebTest
Why? Go beyond built-in features Customize for special needs Make your tests easier to write Make your tests results easier to read
Building blocks WebTest Groovy Apache ANT Apache POI ... HtmlUnit Jakarta commons-httpclient NekoHTML Mozilla Rhino ...
WebTest uses HtmlUnit A “browser for Java programms” 100% pure java, headless Able to simulate FF or IE Very fast and leightweight Used in WebTest but as well in JSFUnit, WebDriver, JWebUnit, Cactus, Celerity, Schnell, ... Very good JS support... but not yet perfect
Go beyond built-in features ... < webtest > < groovy description =&quot; configure NTLM proxy credentials &quot;> step.context.webClient.credentialsProvider.addNTLMProxyCredentials( &quot;michael&quot;, &quot;secret&quot;, &quot;testserver&quot;, 12345, &quot;BlueGene&quot;, &quot;my.windows.domain&quot;)  </ groovy > < invoke url =&quot; http://testserver/ &quot;/> ..... </ webtest > ...
Hack the web connection
Define custom steps Works but: too low level not reusable ... < verifyXPath xpath= &quot;//*[@id='navPath1']”  text= &quot;Home”/> < verifyXPath xpath= &quot;//*[@id='navPath2']”  text= &quot;Functional testing”/> < verifyXPath xpath= &quot;//*[@id='navPath3']”  text= &quot;WebTest”/> ...
Define custom steps < groovyScript   name= &quot;verifyNavPath”><![CDATA[ class  VerifyNavigationPath  extends  com.canoo.webtest.steps.Step  { String  level1, level2, level3, level4 void  doExecute()  { def  ant =  new  AntBuilder(project) def  levels = [0, level1, level2, level3, level4] for  (i  in  1..<levels.size())  { if  (levels[i]) ant.verifyXPath(xpath: &quot;//a[@id='navPath${i}']/text()&quot;, text: levels[i], description: &quot;Verify level ${i}&quot;) } } } project.addTaskDefinition('verifyNavPath', VerifyNavigationPath) ]]></ groovyScript > ... < verifyNavPath level1= &quot;Home”/> < verifyNavPath level1= &quot;Home”  level2= &quot;Functional testing”  level3= &quot;WebTest”/>
Myths & Best Practices
“ UI tests  are brittle by nature”
Determine what you want to test! How to test addition into the basket? clickLink ”Einkaufskorb”? clickLink “Ajax” ? clickLink xpath=”//*[text() = 'Top Angebot']//a” ? clickLink xpath=”//*[text() = '6.60']/following-sibling::a” ? => it depends! These 4 examples  don't test the same thing !
wrong! “ UI tests  are brittle by nature”
“ Tests ensure that the application works”
demo http://new.jugcologne.org
wrong! => tests allow to find errors, that's all “ Tests ensure that the application works”
“ UI tests must run in the browser  to act like real users”
wrong! => a test pilot is not a standard pilot “ UI tests must run in the browser  to act like real users”
“ UI tests are slow”
Speed matters! Execution speed WebTest very fast: no rendering, single process, HtmlUnit's API allows a better control HtmlUnit vs Watir Celerity benchmarks: 69%-99% time reduction Schnell benchmark: 97% time reduction Report analyse speed Very rich reports Debugging (mostly) useless
demo wt.parallel.nbWorkers
wrong! “ UI tests are slow”
WebTest & AJAX
AJAX testing AJAX supported XMLHttpRequest supported since 2005 But AJAX = complex JS libraries AJAX = testing challenge WebTest JS support not yet perfect Simulated browser offers testing facilities
AJAX = testing challenge Selenium & Co' solution: WebTest's solution: BUT not yet perfect - works well with XHR and setTimeout - doesn't work well with setInterval ;-( nothing here! clickButton  &quot;Update&quot; click  &quot;Update&quot; waitForElementPresent  &quot;some elt&quot; click
JS support not yet perfect HtmlUnit JS support continuously improved HtmlUnit/WebTest already used in numerous projects to test AJAX applications Currently supported libraries: GWT, Sarissa, ...
Testing Facility example: mashup unavailability other.server.com www.myserver.com ?
Testing Facility example: mashup unavailability
WebTest's future(s)
WebTest's future(s) Integration of WebDriver Integration with JMeter for load testing ...
Integration with WebDriver N o w WebTest HtmlUnit HtmlUnit WebDriver Firefox IE ... C o m i n g WebTest
demo wt.withFirefox=1
demo WebTest Sampler
Conclusion
Lessons learned Use recorder only to give you a jump start Write testable code write coherent html code add nodes, ids, ... to make testing easier Test early Modulize / Refactor / Reuse code  Customize your test tool Distinguish guaranted from accidental behavior: which changes in the application should make a step fail which changes in the application should NOT make it fail
WebTest key properties simple fast excellent reporting very low TCO runs everywhere no display needed easy to extend straightforward integration js support not as good as in “normal” browser doesn't accept (too) badly formatted html code doesn't accept (too) badly formatted html code
References WebTest http://webtest.canoo.com WebTestRecorder  http://webtestrecorder.canoo.com Mailing list  http://lists.canoo.com/mailman/listinfo/webtest WebTest screencasts Creating a first WebTest project  http://opensource.basehaus.com/webtest/screencasts/creating-a-first-webtest-project.htm Data driven WebTest  http://opensource.basehaus.com/webtest/screencasts/data-driven-webtest.htm HtmlUnit  http://htmlunit.sf.net WebDriver  http://code.google.com/p/webdriver/ JMeter  http://jakarta.apache.org/jmeter/ Why Selenium sucks (Mark Striebeck, Selenium User Meetup)  http://br.youtube.com/watch?v=EDb8yOM3Vpw Groovy  http://groovy.codehaus.org/ AntBuilder  http://groovy.codehaus.org/Using+Ant+from+Groovy Watir  http://wtr.rubyforge.org/ Schnell  http://code.google.com/p/schnell-jruby/ Celerity  http://celerity.rubyforge.org/ JSFUnit  http://www.jboss.org/jsfunit/
Happy testing!

More Related Content

What's hot (20)

PDF
Codeception introduction and use in Yii
IlPeach
 
PPTX
Azure DevOps Realtime Work Item Sync: the good, the bad, the ugly!
Lorenzo Barbieri
 
PPTX
Sync Workitems between multiple Team Projects #vssatpn
Lorenzo Barbieri
 
PPT
Pragmatic Parallels: Java and JavaScript
davejohnson
 
PDF
Codeception
Jonathan Lau
 
PDF
Usability in the GeoWeb
Dave Bouwman
 
PDF
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Joe Ferguson
 
PDF
Efficient JavaScript Unit Testing, May 2012
Hazem Saleh
 
PDF
Web driver selenium simplified
Vikas Singh
 
ZIP
Five Easy Ways to QA Your Drupal Site
Mediacurrent
 
PDF
Beginning AngularJS
Troy Miles
 
PDF
PHP Unit Testing in Yii
IlPeach
 
PPTX
Automated tests
Damian Sromek
 
PDF
Rewrite vs Refactor (AgileIndia 2021)
Anand Bagmar
 
PPT
Gems Of Selenium
Skills Matter
 
PDF
Abstraction Layers Test Management Summit Faciliated Session 2014
Alan Richardson
 
PDF
From Good to Great: Functional and Acceptance Testing in WordPress.
David Aguilera
 
PDF
Php tests tips
Damian Sromek
 
PPTX
Unit testing hippo
Ebrahim Aharpour
 
KEY
HTML5: what's new?
Chris Mills
 
Codeception introduction and use in Yii
IlPeach
 
Azure DevOps Realtime Work Item Sync: the good, the bad, the ugly!
Lorenzo Barbieri
 
Sync Workitems between multiple Team Projects #vssatpn
Lorenzo Barbieri
 
Pragmatic Parallels: Java and JavaScript
davejohnson
 
Codeception
Jonathan Lau
 
Usability in the GeoWeb
Dave Bouwman
 
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Joe Ferguson
 
Efficient JavaScript Unit Testing, May 2012
Hazem Saleh
 
Web driver selenium simplified
Vikas Singh
 
Five Easy Ways to QA Your Drupal Site
Mediacurrent
 
Beginning AngularJS
Troy Miles
 
PHP Unit Testing in Yii
IlPeach
 
Automated tests
Damian Sromek
 
Rewrite vs Refactor (AgileIndia 2021)
Anand Bagmar
 
Gems Of Selenium
Skills Matter
 
Abstraction Layers Test Management Summit Faciliated Session 2014
Alan Richardson
 
From Good to Great: Functional and Acceptance Testing in WordPress.
David Aguilera
 
Php tests tips
Damian Sromek
 
Unit testing hippo
Ebrahim Aharpour
 
HTML5: what's new?
Chris Mills
 

Viewers also liked (10)

PPTX
The Safety Net of Functional Web Testing
ogborstad
 
PPT
Darfur1
mjap23
 
PDF
Sitecore 7: A developers quest to mastering unit testing
nonlinear creations
 
PPTX
Test-Driven Sitecore
Caitlin Portrie
 
PPTX
What are the advantages of non functional testing
Maveric Systems
 
PPTX
Continuous Testing of eCommerce Apps
Sauce Labs
 
PPTX
The importance of non functional testing
Maveric Systems
 
PPTX
Non-functional Testing (NFT) Overview
Assaf Halperin
 
PPT
Non Functional Testing
Nishant Worah
 
PPTX
Testing web services
Taras Lytvyn
 
The Safety Net of Functional Web Testing
ogborstad
 
Darfur1
mjap23
 
Sitecore 7: A developers quest to mastering unit testing
nonlinear creations
 
Test-Driven Sitecore
Caitlin Portrie
 
What are the advantages of non functional testing
Maveric Systems
 
Continuous Testing of eCommerce Apps
Sauce Labs
 
The importance of non functional testing
Maveric Systems
 
Non-functional Testing (NFT) Overview
Assaf Halperin
 
Non Functional Testing
Nishant Worah
 
Testing web services
Taras Lytvyn
 
Ad

Similar to WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond (20)

PDF
Tellurium.A.New.Approach.For.Web.Testing
John.Jian.Fang
 
PDF
Tellurium.A.New.Approach.For.Web.Testing.V5
John.Jian.Fang
 
PPT
Automated Testing Of Web Applications Using XML
diongillard
 
PPTX
4&5.pptx SOFTWARE TESTING UNIT-4 AND UNIT-5
hemasubbu08
 
ZIP
Browser-Based testing using Selenium
ret0
 
PPT
Introduction to Selenium
rohitnayak
 
PPT
Selenium
Purna Chandar
 
PPT
Test strategy for web development
alice yang
 
PPT
selenium.ppt
rajnexient
 
PPT
selenium.ppt
ssuser7b4894
 
PPT
selenium.ppt
AmenSheikh
 
PPT
By combining Selenium for frontend testing and tools
sivanandhumanickam84
 
PPTX
Automated Testing on Web Applications
Samuel Borg
 
PPTX
Automated integration tests for ajax applications (с. карпушин, auriga)
Mobile Developer Day
 
PPTX
Java script unit testing
Mats Bryntse
 
PPTX
Taiko presentation
VodqaBLR
 
PPT
Selenium
Sun Technlogies
 
PPT
Selenium
husnara mohammad
 
PPT
Stepin evening presented
Vijayan Reddy
 
PDF
Web UI test automation instruments
Artem Nagornyi
 
Tellurium.A.New.Approach.For.Web.Testing
John.Jian.Fang
 
Tellurium.A.New.Approach.For.Web.Testing.V5
John.Jian.Fang
 
Automated Testing Of Web Applications Using XML
diongillard
 
4&5.pptx SOFTWARE TESTING UNIT-4 AND UNIT-5
hemasubbu08
 
Browser-Based testing using Selenium
ret0
 
Introduction to Selenium
rohitnayak
 
Selenium
Purna Chandar
 
Test strategy for web development
alice yang
 
selenium.ppt
rajnexient
 
selenium.ppt
ssuser7b4894
 
selenium.ppt
AmenSheikh
 
By combining Selenium for frontend testing and tools
sivanandhumanickam84
 
Automated Testing on Web Applications
Samuel Borg
 
Automated integration tests for ajax applications (с. карпушин, auriga)
Mobile Developer Day
 
Java script unit testing
Mats Bryntse
 
Taiko presentation
VodqaBLR
 
Selenium
Sun Technlogies
 
Stepin evening presented
Vijayan Reddy
 
Web UI test automation instruments
Artem Nagornyi
 
Ad

Recently uploaded (20)

PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Digital Circuits, important subject in CS
contactparinay1
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 

WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond

  • 1. WebTest Efficient Functional Web Testing with HtmlUnit and Beyond Marc Guillemot JUG Cologne 25.08.2008
  • 2. Your speaker French developer exiled in Germany Independent consultant since 2002 Focus on Java, Groovy, Grails and ... web testing HtmlUnit & WebTest lead developer Committer to Groovy & NekoHTML Blog: http://mguillem.wordpress.com Site (coming): http://www.efficient-webtesting.com
  • 3. Agenda Introduction to WebTest Test automation: a software engineering activity Extending WebTest Myths and best practices WebTest and AJAX WebTest's future(s) Conclusion Q & A
  • 4. What I won't say Why you should automate your web application tests How to install WebTest How to integrate into your build Why Selenium sucks ;-)
  • 5. What is WebTest Automated web functional testing tool Open Source (Apache 2 license) Founded in 2001 Currently 4 committers (Germany, Switzerland, USA, Australia) Built on top of Apache Ant http://webtest.canoo.com
  • 6. Who uses WebTest? Open Source project => no idea! Let's look at the mailing list: 700 subscribers [email_address] *@apache.org *@*.gov Akamai, AMD, Axa, Bayer, Boeing, BT, Citigroup, Crédit-Suisse, CSC, DHL, EDS, IBM, Lexmark, Novartis, Oracle, Paypal, Sun, T-Mobile, Thalesgroup, Verisign, Zuehlke, ... => everybody from small to huge
  • 7. demo (on a strange site)
  • 8. Over 100 WebTest Steps General <invoke .../> <clickLink .../> ... Forms <setInputField .../> <setRadioButton .../> <clickButton .../> ... Verification <verifyTitle .../> <verifyXPath .../> <verifyInputField .../> ... PDF <pdfDecryptDocument .../> <pdfVerifyField .../> ... Excel documents <excelFindRow .../> <excelVerifyCellValue .../> ... Email, Applets, ... Comprehensive online documentation http://webtest.canoo.com
  • 10. Apply rules of software engineering Remove duplications Extract modules Use source control Consider modifications and extensions Ant, Java, Groovy
  • 11. XPath Learn XPath Learn XPath!!! Apply it wisely /html/body/div[2]/center/table[3]/tr/td[@id='total'] //*[@id='total'] Write HTML code allowing simple XPath expressions!!!
  • 12. Apply the right testing paradigm Capture / replay Model based testing Data driven testing Scripted automation
  • 14. Model based testing Specification: modelling expected behavior Be tolerant to accidental behavior Example: bad XPath: /html/body/div[2]/center/table[3] better: //*[@id='total'] Fault model: modelling unexpected behavior < not > < verifyText text= &quot;NullPointerException&quot;/> </ not >
  • 16. Scripted automation Maximum flexibility and power Maximum responsibility
  • 18. Why? Go beyond built-in features Customize for special needs Make your tests easier to write Make your tests results easier to read
  • 19. Building blocks WebTest Groovy Apache ANT Apache POI ... HtmlUnit Jakarta commons-httpclient NekoHTML Mozilla Rhino ...
  • 20. WebTest uses HtmlUnit A “browser for Java programms” 100% pure java, headless Able to simulate FF or IE Very fast and leightweight Used in WebTest but as well in JSFUnit, WebDriver, JWebUnit, Cactus, Celerity, Schnell, ... Very good JS support... but not yet perfect
  • 21. Go beyond built-in features ... < webtest > < groovy description =&quot; configure NTLM proxy credentials &quot;> step.context.webClient.credentialsProvider.addNTLMProxyCredentials( &quot;michael&quot;, &quot;secret&quot;, &quot;testserver&quot;, 12345, &quot;BlueGene&quot;, &quot;my.windows.domain&quot;) </ groovy > < invoke url =&quot; http://testserver/ &quot;/> ..... </ webtest > ...
  • 22. Hack the web connection
  • 23. Define custom steps Works but: too low level not reusable ... < verifyXPath xpath= &quot;//*[@id='navPath1']” text= &quot;Home”/> < verifyXPath xpath= &quot;//*[@id='navPath2']” text= &quot;Functional testing”/> < verifyXPath xpath= &quot;//*[@id='navPath3']” text= &quot;WebTest”/> ...
  • 24. Define custom steps < groovyScript name= &quot;verifyNavPath”><![CDATA[ class VerifyNavigationPath extends com.canoo.webtest.steps.Step { String level1, level2, level3, level4 void doExecute() { def ant = new AntBuilder(project) def levels = [0, level1, level2, level3, level4] for (i in 1..<levels.size()) { if (levels[i]) ant.verifyXPath(xpath: &quot;//a[@id='navPath${i}']/text()&quot;, text: levels[i], description: &quot;Verify level ${i}&quot;) } } } project.addTaskDefinition('verifyNavPath', VerifyNavigationPath) ]]></ groovyScript > ... < verifyNavPath level1= &quot;Home”/> < verifyNavPath level1= &quot;Home” level2= &quot;Functional testing” level3= &quot;WebTest”/>
  • 25. Myths & Best Practices
  • 26. “ UI tests are brittle by nature”
  • 27. Determine what you want to test! How to test addition into the basket? clickLink ”Einkaufskorb”? clickLink “Ajax” ? clickLink xpath=”//*[text() = 'Top Angebot']//a” ? clickLink xpath=”//*[text() = '6.60']/following-sibling::a” ? => it depends! These 4 examples don't test the same thing !
  • 28. wrong! “ UI tests are brittle by nature”
  • 29. “ Tests ensure that the application works”
  • 31. wrong! => tests allow to find errors, that's all “ Tests ensure that the application works”
  • 32. “ UI tests must run in the browser to act like real users”
  • 33. wrong! => a test pilot is not a standard pilot “ UI tests must run in the browser to act like real users”
  • 34. “ UI tests are slow”
  • 35. Speed matters! Execution speed WebTest very fast: no rendering, single process, HtmlUnit's API allows a better control HtmlUnit vs Watir Celerity benchmarks: 69%-99% time reduction Schnell benchmark: 97% time reduction Report analyse speed Very rich reports Debugging (mostly) useless
  • 37. wrong! “ UI tests are slow”
  • 39. AJAX testing AJAX supported XMLHttpRequest supported since 2005 But AJAX = complex JS libraries AJAX = testing challenge WebTest JS support not yet perfect Simulated browser offers testing facilities
  • 40. AJAX = testing challenge Selenium & Co' solution: WebTest's solution: BUT not yet perfect - works well with XHR and setTimeout - doesn't work well with setInterval ;-( nothing here! clickButton &quot;Update&quot; click &quot;Update&quot; waitForElementPresent &quot;some elt&quot; click
  • 41. JS support not yet perfect HtmlUnit JS support continuously improved HtmlUnit/WebTest already used in numerous projects to test AJAX applications Currently supported libraries: GWT, Sarissa, ...
  • 42. Testing Facility example: mashup unavailability other.server.com www.myserver.com ?
  • 43. Testing Facility example: mashup unavailability
  • 45. WebTest's future(s) Integration of WebDriver Integration with JMeter for load testing ...
  • 46. Integration with WebDriver N o w WebTest HtmlUnit HtmlUnit WebDriver Firefox IE ... C o m i n g WebTest
  • 50. Lessons learned Use recorder only to give you a jump start Write testable code write coherent html code add nodes, ids, ... to make testing easier Test early Modulize / Refactor / Reuse code Customize your test tool Distinguish guaranted from accidental behavior: which changes in the application should make a step fail which changes in the application should NOT make it fail
  • 51. WebTest key properties simple fast excellent reporting very low TCO runs everywhere no display needed easy to extend straightforward integration js support not as good as in “normal” browser doesn't accept (too) badly formatted html code doesn't accept (too) badly formatted html code
  • 52. References WebTest http://webtest.canoo.com WebTestRecorder http://webtestrecorder.canoo.com Mailing list http://lists.canoo.com/mailman/listinfo/webtest WebTest screencasts Creating a first WebTest project http://opensource.basehaus.com/webtest/screencasts/creating-a-first-webtest-project.htm Data driven WebTest http://opensource.basehaus.com/webtest/screencasts/data-driven-webtest.htm HtmlUnit http://htmlunit.sf.net WebDriver http://code.google.com/p/webdriver/ JMeter http://jakarta.apache.org/jmeter/ Why Selenium sucks (Mark Striebeck, Selenium User Meetup) http://br.youtube.com/watch?v=EDb8yOM3Vpw Groovy http://groovy.codehaus.org/ AntBuilder http://groovy.codehaus.org/Using+Ant+from+Groovy Watir http://wtr.rubyforge.org/ Schnell http://code.google.com/p/schnell-jruby/ Celerity http://celerity.rubyforge.org/ JSFUnit http://www.jboss.org/jsfunit/