SlideShare ist ein Scribd-Unternehmen logo
1 von 41
Les DSL et "fluent interface" pour les tests ASP.NET avec Selenium FluentSelenium
Content ,[object Object]
Best practices for testing
FluentSelenium
Conclusion
Selenium introduction Selenium is a suite of tools to automate web app testing across many platforms ,[object Object],[object Object],[object Object]
Here's a web test written with selenium selenium.Open( "Forum/AllPosts.aspx" ); selenium.WaitForPageToLoad( "8000" ); selenium.Click( "newPost" ); selenium.WaitForPageToLoad( "8000" ); selenium.Type( "//*[contains(@id, 'txtAuthor')]" ,  "Luc" ); selenium.Type( "//*[contains(@id, 'txtSubject')]" ,  "Simple example of the library." ); selenium.Click( "//*[contains(@id, 'btnSavePost')]" ); selenium.WaitForPageToLoad( "8000" ); Assert .AreEqual( "Luc" , selenium.GetText( "//table[contains(@id, 'grdPosts')]//tr[2]/td[2]" ));
Xpath introduction XPath is a structred XML query language Example : get the node of the employee with ID 123456 Employees/Employee[@EmployeeID='123456'] < Employees > < Employee   EmployeeID = &quot; 123456 &quot; > < LastName > Laporte </ LastName > < FirstName > Jacques </ FirstName > </ Employee > < Employee   EmployeeID = &quot; 654321 &quot; > < LastName > Gendron </ LastName > < FirstName > Pierre </ FirstName > </ Employee > </ Employees >
Xpath introduction XPath is a structred XML query language Example : get the last name of the employee with ID 123456 : Employees/Employee[@EmployeeID='123456']/LastName < Employees > < Employee   EmployeeID = &quot; 123456 &quot; > < LastName > Laporte </ LastName > < FirstName > Jacques </ FirstName > </ Employee > < Employee   EmployeeID = &quot; 654321 &quot; > < LastName > Gendron </ LastName > < FirstName > Pierre </ FirstName > </ Employee > </ Employees >
Selenium and XPath on HTML Because HTML is an XML derivative, XPath can be used to locate nodes in a HTML web page Example : ask selenium to click on the Save button : selenium.Click(“//input[@id='btnSubmit']”); selenium.WaitForPageToLoad(“5000”); < html > < body > < form > < div >Hello World !</ div > < input   type = &quot; submit &quot;   value = &quot; Save &quot;   id = &quot; btnSubmit &quot;  /> </ form > </ body > </ html >
Complete simple web test with selenium
Content ,[object Object],[object Object]
FluentSelenium
Conclusion
Good testing practices ,[object Object]
Test independance
Test clarity
Test coverage Should we aim for 100% coverage?
The trade offs
What does this mean? Integrated  tests Unit tests Test coverage
Best practices of test coverage ,[object Object]
Favor coverage through testing of services and domain objects over UI testing
Use patterns that facilitate testing close to the UI layer such as  MVC
Aim for coverage that gives you confidence in the quality of your deliverables
[object Object],Keep tests independent because: ,[object Object]
They will be easier to read
They will not be impacted by updates in other tests
Some things to consider... ,[object Object],[object Object]
Database: Sqlite ,[object Object]
Test Clarity ,[object Object]
Tests are code also. Team code quality rules should also be applied to tests.
XPATH is dangerous, use it wisely Use ID-based queries when possible //*[@id = 'searchResultCount']
Avoid exessive XPATH steps When requiring further qualification in searches only add necessary qualifiers Favor //*[@id='searchResults']//li[1] Over /html/body//div[@id='searchResults']/ul/li[1]
XPATH queries are not clear Xpath expressions are the kind of literal who's meaning can be hard to decipher.  Use constants. Favor selenium.GetText(SearchResultSummaryLocator); Over selenium.GetText( &quot;//*[@id='searchResultsSummary']&quot; );
Keep the test code clean ,[object Object]
Hard to read tests are hard maintain
Tests serve as application behavior documentation
The importance of language in tests ,[object Object]
[object Object],[object Object]
Users
Testers

Weitere ähnliche Inhalte

Was ist angesagt?

Tdd in php a brief example
Tdd in php   a brief exampleTdd in php   a brief example
Tdd in php a brief example
Jeremy Kendall
 
Beyond Unit Testing
Beyond Unit TestingBeyond Unit Testing
Beyond Unit Testing
Søren Lund
 
TDD in PHP - Memphis PHP 2011-08-25
TDD in PHP - Memphis PHP 2011-08-25TDD in PHP - Memphis PHP 2011-08-25
TDD in PHP - Memphis PHP 2011-08-25
Jeremy Kendall
 

Was ist angesagt? (20)

Tdd in php a brief example
Tdd in php   a brief exampleTdd in php   a brief example
Tdd in php a brief example
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Beyond Unit Testing
Beyond Unit TestingBeyond Unit Testing
Beyond Unit Testing
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven Development
 
Behavior Driven Development with SpecFlow
Behavior Driven Development with SpecFlowBehavior Driven Development with SpecFlow
Behavior Driven Development with SpecFlow
 
TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And Refactoring
 
Unit Testing in Action - C#, NUnit, and Moq
Unit Testing in Action - C#, NUnit, and MoqUnit Testing in Action - C#, NUnit, and Moq
Unit Testing in Action - C#, NUnit, and Moq
 
TDD in PHP - Memphis PHP 2011-08-25
TDD in PHP - Memphis PHP 2011-08-25TDD in PHP - Memphis PHP 2011-08-25
TDD in PHP - Memphis PHP 2011-08-25
 
Unit Tests And Automated Testing
Unit Tests And Automated TestingUnit Tests And Automated Testing
Unit Tests And Automated Testing
 
Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)
 
Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010
 
Reduce Reuse Refactor
Reduce Reuse RefactorReduce Reuse Refactor
Reduce Reuse Refactor
 
TDD - Agile
TDD - Agile TDD - Agile
TDD - Agile
 
Testing the untestable
Testing the untestableTesting the untestable
Testing the untestable
 
Behaviour Driven Development with SpecFlow
Behaviour Driven Development with SpecFlowBehaviour Driven Development with SpecFlow
Behaviour Driven Development with SpecFlow
 
An Introduction to Test Driven Development
An Introduction to Test Driven Development An Introduction to Test Driven Development
An Introduction to Test Driven Development
 
Software Quality via Unit Testing
Software Quality via Unit TestingSoftware Quality via Unit Testing
Software Quality via Unit Testing
 
A Brief Introduction to Zend_Form
A Brief Introduction to Zend_FormA Brief Introduction to Zend_Form
A Brief Introduction to Zend_Form
 
Unit testing
Unit testing Unit testing
Unit testing
 
Codeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansaiCodeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansai
 

Ähnlich wie FluentSelenium Presentation Code Camp09

Web App Testing With Selenium
Web App Testing With SeleniumWeb App Testing With Selenium
Web App Testing With Selenium
joaopmaia
 

Ähnlich wie FluentSelenium Presentation Code Camp09 (20)

Selenium
SeleniumSelenium
Selenium
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
Web App Testing With Selenium
Web App Testing With SeleniumWeb App Testing With Selenium
Web App Testing With Selenium
 
Functional Testing Swing Applications with Frankenstein
Functional Testing Swing Applications with FrankensteinFunctional Testing Swing Applications with Frankenstein
Functional Testing Swing Applications with Frankenstein
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2
 
Eclipse 40 and Eclipse e4
Eclipse 40 and Eclipse e4 Eclipse 40 and Eclipse e4
Eclipse 40 and Eclipse e4
 
Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010
 
Selenium
SeleniumSelenium
Selenium
 
Susan windsor soft test 16th november 2005
Susan windsor soft test   16th november 2005Susan windsor soft test   16th november 2005
Susan windsor soft test 16th november 2005
 
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-publicJavazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
 
Interview Question & Answers for Selenium Freshers | LearningSlot
Interview Question & Answers for Selenium Freshers | LearningSlotInterview Question & Answers for Selenium Freshers | LearningSlot
Interview Question & Answers for Selenium Freshers | LearningSlot
 
Testing Ajax Web Applications
Testing Ajax Web ApplicationsTesting Ajax Web Applications
Testing Ajax Web Applications
 
Introduction to JSF
Introduction toJSFIntroduction toJSF
Introduction to JSF
 
Improving code quality using CI
Improving code quality using CIImproving code quality using CI
Improving code quality using CI
 
Struts2
Struts2Struts2
Struts2
 
Automated Testing Of Web Applications Using XML
Automated  Testing Of  Web  Applications Using  XMLAutomated  Testing Of  Web  Applications Using  XML
Automated Testing Of Web Applications Using XML
 
About Qtp 92
About Qtp 92About Qtp 92
About Qtp 92
 
About QTP 9.2
About QTP 9.2About QTP 9.2
About QTP 9.2
 
About Qtp_1 92
About Qtp_1 92About Qtp_1 92
About Qtp_1 92
 

Mehr von Pyxis Technologies

Pitié, ne construisez pas le nouveau pont Champlain en Agilité...
Pitié, ne construisez pas le nouveau pont Champlain en Agilité...Pitié, ne construisez pas le nouveau pont Champlain en Agilité...
Pitié, ne construisez pas le nouveau pont Champlain en Agilité...
Pyxis Technologies
 
Estimation initiale dun projet agile de Mathieu Boisvert
Estimation initiale dun projet agile de Mathieu BoisvertEstimation initiale dun projet agile de Mathieu Boisvert
Estimation initiale dun projet agile de Mathieu Boisvert
Pyxis Technologies
 
Apprendre pour la performance et le bien-être
Apprendre pour la performance et le bien-êtreApprendre pour la performance et le bien-être
Apprendre pour la performance et le bien-être
Pyxis Technologies
 

Mehr von Pyxis Technologies (20)

Pitié, ne construisez pas le nouveau pont Champlain en Agilité...
Pitié, ne construisez pas le nouveau pont Champlain en Agilité...Pitié, ne construisez pas le nouveau pont Champlain en Agilité...
Pitié, ne construisez pas le nouveau pont Champlain en Agilité...
 
Sorry, the new Champlain Bridge can’t be built using Agile...
Sorry, the new Champlain Bridge can’t be built using Agile...Sorry, the new Champlain Bridge can’t be built using Agile...
Sorry, the new Champlain Bridge can’t be built using Agile...
 
Développer votre logiciel interne : comment y parvenir sans investir une fort...
Développer votre logiciel interne : comment y parvenir sans investir une fort...Développer votre logiciel interne : comment y parvenir sans investir une fort...
Développer votre logiciel interne : comment y parvenir sans investir une fort...
 
Agilité du point de vue de la gouvernance
Agilité du point de vue de la gouvernanceAgilité du point de vue de la gouvernance
Agilité du point de vue de la gouvernance
 
La gestion de portefeuille Agile - c'est pas compliqué!
La gestion de portefeuille Agile - c'est pas compliqué! La gestion de portefeuille Agile - c'est pas compliqué!
La gestion de portefeuille Agile - c'est pas compliqué!
 
Introduction à Agile Lean
Introduction à Agile LeanIntroduction à Agile Lean
Introduction à Agile Lean
 
La valeur d'affaires comme indicateur de la gestion de projet - IIBA Montréal...
La valeur d'affaires comme indicateur de la gestion de projet - IIBA Montréal...La valeur d'affaires comme indicateur de la gestion de projet - IIBA Montréal...
La valeur d'affaires comme indicateur de la gestion de projet - IIBA Montréal...
 
Agile BA - catalyseur, createur de valeur - BAFS 29 juin 2015 Geneve
Agile BA - catalyseur, createur de valeur - BAFS 29 juin 2015 Geneve Agile BA - catalyseur, createur de valeur - BAFS 29 juin 2015 Geneve
Agile BA - catalyseur, createur de valeur - BAFS 29 juin 2015 Geneve
 
Estimation initiale dun projet agile de Mathieu Boisvert
Estimation initiale dun projet agile de Mathieu BoisvertEstimation initiale dun projet agile de Mathieu Boisvert
Estimation initiale dun projet agile de Mathieu Boisvert
 
Les attitudes doxiques dans les équipes et le syndrome du Titanic!
Les attitudes doxiques dans les équipes et le syndrome du Titanic!Les attitudes doxiques dans les équipes et le syndrome du Titanic!
Les attitudes doxiques dans les équipes et le syndrome du Titanic!
 
La valeur d’affaires: L’indicateur qui peut changer le succès des projets
La valeur d’affaires: L’indicateur qui peut changer le succès des projetsLa valeur d’affaires: L’indicateur qui peut changer le succès des projets
La valeur d’affaires: L’indicateur qui peut changer le succès des projets
 
Danser avec les polarités
Danser avec les polaritésDanser avec les polarités
Danser avec les polarités
 
Le rôle de l’architecte Agile - Mathieu Boisvert
Le rôle de l’architecte Agile - Mathieu BoisvertLe rôle de l’architecte Agile - Mathieu Boisvert
Le rôle de l’architecte Agile - Mathieu Boisvert
 
Agilité et la gestion du changement mboisvert - 15 octobre 2013
Agilité et la gestion du changement   mboisvert - 15 octobre 2013Agilité et la gestion du changement   mboisvert - 15 octobre 2013
Agilité et la gestion du changement mboisvert - 15 octobre 2013
 
Comment être agile dans un contexte non lié aux TI ?
Comment être agile dans un contexte non lié aux TI ?Comment être agile dans un contexte non lié aux TI ?
Comment être agile dans un contexte non lié aux TI ?
 
La revue d'itération intégrée… Et autres fabuleuses pratiques Agiles adaptées...
La revue d'itération intégrée… Et autres fabuleuses pratiques Agiles adaptées...La revue d'itération intégrée… Et autres fabuleuses pratiques Agiles adaptées...
La revue d'itération intégrée… Et autres fabuleuses pratiques Agiles adaptées...
 
Choisir ses priorités: le développement incrémental de produit
Choisir ses priorités: le développement incrémental de produitChoisir ses priorités: le développement incrémental de produit
Choisir ses priorités: le développement incrémental de produit
 
Apprendre pour la performance et le bien-être
Apprendre pour la performance et le bien-êtreApprendre pour la performance et le bien-être
Apprendre pour la performance et le bien-être
 
L'agilité : de l'individu à l'organisation en passant par l'équipe
L'agilité : de l'individu à l'organisation en passant par l'équipeL'agilité : de l'individu à l'organisation en passant par l'équipe
L'agilité : de l'individu à l'organisation en passant par l'équipe
 
Agile du point de vue d'un PMP
Agile du point de vue d'un PMPAgile du point de vue d'un PMP
Agile du point de vue d'un PMP
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

FluentSelenium Presentation Code Camp09

  • 1. Les DSL et &quot;fluent interface&quot; pour les tests ASP.NET avec Selenium FluentSelenium
  • 2.
  • 6.
  • 7. Here's a web test written with selenium selenium.Open( &quot;Forum/AllPosts.aspx&quot; ); selenium.WaitForPageToLoad( &quot;8000&quot; ); selenium.Click( &quot;newPost&quot; ); selenium.WaitForPageToLoad( &quot;8000&quot; ); selenium.Type( &quot;//*[contains(@id, 'txtAuthor')]&quot; , &quot;Luc&quot; ); selenium.Type( &quot;//*[contains(@id, 'txtSubject')]&quot; , &quot;Simple example of the library.&quot; ); selenium.Click( &quot;//*[contains(@id, 'btnSavePost')]&quot; ); selenium.WaitForPageToLoad( &quot;8000&quot; ); Assert .AreEqual( &quot;Luc&quot; , selenium.GetText( &quot;//table[contains(@id, 'grdPosts')]//tr[2]/td[2]&quot; ));
  • 8. Xpath introduction XPath is a structred XML query language Example : get the node of the employee with ID 123456 Employees/Employee[@EmployeeID='123456'] < Employees > < Employee EmployeeID = &quot; 123456 &quot; > < LastName > Laporte </ LastName > < FirstName > Jacques </ FirstName > </ Employee > < Employee EmployeeID = &quot; 654321 &quot; > < LastName > Gendron </ LastName > < FirstName > Pierre </ FirstName > </ Employee > </ Employees >
  • 9. Xpath introduction XPath is a structred XML query language Example : get the last name of the employee with ID 123456 : Employees/Employee[@EmployeeID='123456']/LastName < Employees > < Employee EmployeeID = &quot; 123456 &quot; > < LastName > Laporte </ LastName > < FirstName > Jacques </ FirstName > </ Employee > < Employee EmployeeID = &quot; 654321 &quot; > < LastName > Gendron </ LastName > < FirstName > Pierre </ FirstName > </ Employee > </ Employees >
  • 10. Selenium and XPath on HTML Because HTML is an XML derivative, XPath can be used to locate nodes in a HTML web page Example : ask selenium to click on the Save button : selenium.Click(“//input[@id='btnSubmit']”); selenium.WaitForPageToLoad(“5000”); < html > < body > < form > < div >Hello World !</ div > < input type = &quot; submit &quot; value = &quot; Save &quot; id = &quot; btnSubmit &quot; /> </ form > </ body > </ html >
  • 11. Complete simple web test with selenium
  • 12.
  • 15.
  • 18. Test coverage Should we aim for 100% coverage?
  • 20. What does this mean? Integrated tests Unit tests Test coverage
  • 21.
  • 22. Favor coverage through testing of services and domain objects over UI testing
  • 23. Use patterns that facilitate testing close to the UI layer such as MVC
  • 24. Aim for coverage that gives you confidence in the quality of your deliverables
  • 25.
  • 26. They will be easier to read
  • 27. They will not be impacted by updates in other tests
  • 28.
  • 29.
  • 30.
  • 31. Tests are code also. Team code quality rules should also be applied to tests.
  • 32. XPATH is dangerous, use it wisely Use ID-based queries when possible //*[@id = 'searchResultCount']
  • 33. Avoid exessive XPATH steps When requiring further qualification in searches only add necessary qualifiers Favor //*[@id='searchResults']//li[1] Over /html/body//div[@id='searchResults']/ul/li[1]
  • 34. XPATH queries are not clear Xpath expressions are the kind of literal who's meaning can be hard to decipher. Use constants. Favor selenium.GetText(SearchResultSummaryLocator); Over selenium.GetText( &quot;//*[@id='searchResultsSummary']&quot; );
  • 35.
  • 36. Hard to read tests are hard maintain
  • 37. Tests serve as application behavior documentation
  • 38.
  • 39.
  • 40. Users
  • 42. Technical writers Write tests in your audiences language!
  • 43.
  • 44.
  • 45. Nhibernate and Linq use query oriented languages
  • 46. Users speak in the language of their needs and tasks
  • 47. Programmers tend to speak in terms of technical jargon In code this translates to the choice vocabulary used in class, method and variable names. Tests should use a DSL appropriate to the end user.
  • 48.
  • 49.
  • 52. Some examples shopper.Goto( &quot;Shopping/ShopOnline.aspx&quot; ); shopper.For(WelcomeMessageBox).ShouldSee( &quot;Welcome to Shop-e online!&quot; ); shopper.ShouldSee(FeaturedProductArea); shopper.For(FeaturedProductTitle).ShouldSee( &quot;blank CDs (10)&quot; ); shopper.For(FeaturedProductUnitePriceField).ShouldSee( &quot;5.00$&quot; );
  • 53. selenium.Open( &quot;Shopping/ShopOnline.aspx&quot; ); selenium.WaitForPageToLoad( &quot;1000&quot; ); Assert .AreEqual( &quot;Welcome to Shop-e online!&quot; , selenium.GetText( &quot;welcome&quot; )); Assert .IsTrue(selenium.IsVisible( &quot;featuredProduct&quot; )); Assert .AreEqual( &quot;blank CDs (10)&quot; , selenium.GetText( &quot;//*[@id='featuredProduct']//*[@id='title']&quot; )); Assert .AreEqual( &quot;5,00$&quot; , selenium.GetText( &quot;//*[@id='featuredProduct']//*[@id='price']&quot; ));
  • 54. ... forumUser.Goto( &quot;Forum/AllPosts.aspx&quot; ); forumUser.For(addPostButton).Clicks(); forumUser.WaitFor(newPostPageLoadWait); forumUser.For(subjectTextBox).Enters( &quot;Simple example of the library.&quot; ); forumUser.For(messagetTextBox).Enters( &quot;blah&quot; ); forumUser.For(savePostButton).Clicks(); forumUser.For(authorRequiredMessage).ShouldSee( &quot;The author is required.&quot; );
  • 55. The User The User class is the root of the DSL. All web test operations spawn from it. It is initialized as follows: var selenium = new DefaultSelenium (....); var forumUser = new User (selenium); Variables of type User should be named according to the role of the application user.
  • 56. Pushing XPATH out of the tests FluentSelenium uses typed locator objects ElementLocator WelcomeMessageBox = ElementLocator .WithId( &quot;welcome&quot; ); InputLocator SearchCatalogText = InputLocator .WithId( &quot;searchText&quot; ); ButtonLocator SearchCatalogButton = ButtonLocator .WithId( &quot;searchButton&quot; ); ElementLocator FeaturedProductTitle = ElementLocator .WithXpath( &quot;//*[@id='featuredProduct']//*[@id='title']&quot; ); Locator types determine what operations are available with a “For” shopper.For(SearchCatalogText).Enters( &quot;mouse&quot; ); shopper.For(SearchCatalogButton).Clicks();
  • 57. Application navigation Navigating to a specific address: goto shopper.Goto( &quot;Shopping/ShopOnline.aspx&quot; ); Navigating by clicking on links and buttons: click shopper.For(DiscountsButton).Clicks(); Waiting for page loading: WaitFor PageLoadWaitCondition SearchResultPageLoad = PageLoadWaitCondition .For( &quot;Shopping/SearchResults.aspx&quot; ); shopper.WaitFor(SearchResultPageLoad); Waiting for special conditions can be done by writing a custom implementation of IWaitCondition
  • 58. Validating page content Presence or absence of an element shopper.ShouldSee(WelcomeMessageBox); shopper.ShouldNotSee(SearchResults); Content of an page element shopper.For(SearchResultsSummary).ShouldSee( &quot;1 match found&quot; ); Custom validation, any implementation of IContentValidator class AnyNumberValidator : IContentValidator { public void Validate( ContentTester contentTester) .... shopper.For(OrderNumber).ShouldSee(AnyNumber);
  • 59. Testing table content Testing the content of a table row f orumUser.For(allPostsTable).Row(2).ShouldSee( &quot;Luc&quot; , &quot;Hello&quot; ); Jim Nothing Luc Hello Bob Goodbye Testing the content of a table column forumUser.For(allPostsTable).Column(1).ShouldSee( &quot;Jim&quot;, &quot;Luc&quot;, “Bob” ); Jim Nothing Luc Hello Bob Goodbye
  • 60. Other table operations Checking cell content forumUser.For(allPostsTable).Row(2).Column(3).ShouldSee( &quot;Present&quot; ); Cells have content forumUser.For(allPostsTable).Row(2).Column(3).For(replyPostButton).Click();
  • 61.
  • 62.
  • 63. Use extension methods to add test methods to the User class
  • 64.
  • 66.
  • 67.
  • 68. A simplified spin off of a framework developed for one of our clients. We expect to extend it with ideas and concepts that aren't yet implemented
  • 69. A work in progress
  • 70. A facilitator, not a solution
  • 71.