HtmlUnit... un browser senza GUI per applicazioni Java

Eseguire test automatizzati sulle applicazioni web non è mai stata una operazione semplice. Con l'avvento di JavaEE 5 e dei POJO "annotati" tutto è diventato molto più semplice per lo meno riguardo la business logic. Di tanto in tanto si legge in giro di qualche progetto "promettente" per quanto riguarda il testing dello strato presentation, ma, per quanto mi riguarda, fino ad oggi non avevo mai trovato uno strumento pienamente soddisfacente. Qualche giorno fa mi sono imbattuto in una news che parlava del rilascio della versione 2.1 di HtmlUnit ed incuriosito ho deciso di provarlo. Questo è l'elenco delle features:

  • Support for the HTTP and HTTPS protocols.
  • Support for cookies
  • Ability to specify whether failing responses from the server should throw exceptions or should be returned as pages of the appropriate type (based on content type)
  • Support for submit methods POST and GET (as well as HEAD, DELETE, ...)
  • Ability to customize the request headers being sent to the server
  • Support for HTML responses
    * Wrapper for HTML pages that provides easy access to all information contained inside them
    * Support for submitting forms
    * Support for clicking links
    * Support for walking the DOM model of the HTML document
  • Proxy server support
  • Support for basic and NTLM authentication
  • Good support for JavaScript (see the JavaScript section below)

Oltre che ai test automatizzati lo strumento si presta ottimamente a tutte quelle situazioni dove è necessario interagire, via codice, con delle pagine web (ottimo anche per fare "web scraping").

Consiglio a tutti di provarlo!

Cerca
Login utente
Chi è online
Ci sono attualmente 0 utenti e 0 visitatori collegati.