SlideShare uma empresa Scribd logo
1 de 22
Agile Testing
Automatizzare i test con Selenium IDE

di Stefano Trojani
By Stefano Trojani

1
Automatizzare i test con Selenium IDE

Cosa è Selenium IDE

2
By Stefano Trojani – All rights reserved
Automatizzare i test con Selenium IDE
Cos’è Selenium IDE
Selenium è software di automazione dei test Web Based Open Source
Selenium è un tool che supporta il rapido sviluppo di test automatici web-based
Selenium funziona ovunque sia supportato il javascritp (quindi es: non dentro il flash)
Selenium può essere agganciato a altri linguaggio come: java, php, ruby, python…
Selenium scrive Test Cases usando differenti linguaggi tra cui l’HTML

3
By Stefano Trojani – All rights reserved
Automatizzare i test con Selenium IDE
I vantaggi nell’uso di Selenium IDE
Selenium IDE è gratis
Selenium IDE è facile da installare come plugin di Mozilla Firefox

Selenium IDE può creare Test Case in modo molto facile (semplicemente
«registrando» la navigazione nel browser)
Selenium IDE può essere usato in modo più «puntuale» investigando il codice (es: con
firebug) per identificare dei blocci di codice univoci da richiamare

4
By Stefano Trojani – All rights reserved
Automatizzare i test con Selenium IDE
Installare Selenium IDE
1) Selenium può essere installato semplicemente usando il Browser Firefox e
scaricando IDE dalla pagina del sito SeleniumHQ
http://www.seleniumhq.org/download/

2) Selezionare “Install Now”
3) Una volta installato sarà necessario
riavviare il Browser

5
By Stefano Trojani – All rights reserved
Automatizzare i test con Selenium IDE
Avviare Selenium IDE
Per avviare Selenium IDE basterà
cliccare “opzioni” di Firefox e
successivamente cliccare sull’icona
corrispondente.

Scorciatoia (Ctrl+Alt+S)

6
By Stefano Trojani – All rights reserved
L’interfaccia di Selenim IDE
Comandi di esecuzione

Tasto “registra”
Spazio dedicato ai comandi

Interfaccia di inserimento comandi

Finestra di Log, Reference, etc…

7
By Stefano Trojani – All rights reserved
Automatizzare i test con Selenium IDE
I comandi più usati (e semplici)
AZIONE

COMANDO

Aprire una pagina

open

Cliccare un ogetto nella pagina

click o clickAndWait

Inserire dei valori nelle textarea (es: uno username)

type

Selezionare un valore da una dropdown

select

Salvare un variable

store

Verificare un contenuto della pagina

verifyTextPresent

8
By Stefano Trojani – All rights reserved
Automatizzare i test con Selenium IDE

Rimbocchiamoci le maniche:
Creiamo un Test Case di prova

9
By Stefano Trojani – All rights reserved
Automatizzare i test con Selenium IDE
Creazione di un Test Case di prova
Proviamo adesso a creare un
Test Case usando Selenium IDE
sempicemente “registando” le azioni.
Testeremo la Login ad una webmail su
un importante sito web.

La login su cui vogliamo fare il TC

10
By Stefano Trojani – All rights reserved
Automatizzare i test con Selenium IDE
«Registrazione» di un Test Case
1) Avviamo la “registazione”
2) Facciamo le operazioni sul sito
web (loggiamoci)
3) Stoppiamo la registrazione

La login su cui vogliamo fare il TC
By Stefano Trojani – All rights reserved

11
Automatizzare i test con Selenium IDE
Esecuzione del Test Case
Basterà pigiare l’icona

per far rieseguire le stesse operazioni a Selenium IDE

Nota: A video il browser inizierà a muoversi facendo le stesse operazioni che
abbiamo registrato.

12
By Stefano Trojani – All rights reserved
Automatizzare i test con Selenium IDE
Analizziamo un po’ il codice generato….
Test Case scritto “registrando”
open - http://www.webamil.sito.com
selectWindow - null
type - div[3]/div/div[1]/div[2]/div[2]/form/fieldset/input[1] - USERNAME
Type - div[3]/div/div[1]/div[2]/div[2]/form/fieldset/input[2] - PASSWORD
Select div[3]/div/div[1]/div[2]/div[2]/form/fieldset/div[2]/input - label=Open-Xchange
clickAndWait - name=login
Pause - 1000
Codice “sporco” es: xpath

13
By Stefano Trojani – All rights reserved
Automatizzare i test con Selenium IDE
Tre tipi di “pulizia” nel codice
xpath
type - div[3]/div/div[1]/div[2]/div[2]/form/fieldset/input[1] – USERNAME

 Facile da usare (ci sono anche plugin)
Pericoloso da manutenere (basta cambiare un tag nell’intera pagina ed il test smette di funzionare)
css
type - //input[@class=‘subject’] – USERNAME

 abbastanza sicuro e stabile
 Laborioso a identificare (meglio usare Firebug)
id

type – id=writer_field_to- USERNAME

 Sicuro, univoco, pulito
Raramente il codice delle pagine è così pulito da avere un ID per ogni oggetto
By Stefano Trojani – All rights reserved

14
Automatizzare i test con Selenium IDE
Ispezioniamo il codice per migliorarlo
Analizziamo un po’ il
codice della pagina con
Firebug
https://addons.mozilla.org/enUS/firefox/addon/firebug/

E cerchiamo di
identificare gli
elementi nel codice per
renderlo più “pulito”…

15
By Stefano Trojani – All rights reserved
Automatizzare i test con Selenium IDE
Guardiamo i “miglioramenti” del test case
Test Case corretto manualmente (utilizzando firebug)
open - http://www.webamil.sito.com
selectWindow - null
type - name=user_name - USERNAME
Type - name=user_pass - PASSWORD
Select - name=webmail - label=Open-Xchange
clickAndWait - name=login
Pause - 1000
Codice “pulito” ed univoco

16
By Stefano Trojani – All rights reserved
Automatizzare i test con Selenium IDE
Creazione di Suite
E’ possibile inoltre creare delle
Suite:

un insieme di test case di Selenium
che possono essere eseguiti tutti
insieme
(a cascata) semplicemente
pigiando il bottone
su Selenim
IDE

Una suite di test formata da tanti test case

By Stefano Trojani – All rights reserved

17
Automatizzare i test con Selenium IDE

Allora… ho trovato il paradiso!
No, ci dei limiti…

18
By Stefano Trojani – All rights reserved
Automatizzare i test con Selenium IDE
I limiti di Selenium IDE
Selenium IDE funziona solo come plugin sul Browser Firefox (non è quindi possibile
trstare altri browser)
Selenium IDE supporta solo script scritti nel suo linguaggio proprietario (Selense)
Selenium IDE incontra forti problemi nella gestione di contenuti complessi o dinamici
(es: iframes, istanze javascript, ajax, codice html «sporco»…)

19
By Stefano Trojani – All rights reserved
Automatizzare i test con Selenium IDE

Rassumendo

 Pregi
Selenium IDE permette di testare in modo semplice (con differenti livelli di
complessità che dipendono dalla conoscenza del prodotto) interfacce HTML.
Possono essere gestiti molti test case raccolti in Suite ed eseguiti tutti insieme.

 Svantaggi

Selenium IDE funziona solo come plugin sul Browser Firefox (non è quindi possibile
trstare altri browser) ed incontra forti problemi nella gestione di contenuti complessi
o dinamici

20
By Stefano Trojani – All rights reserved
Automatizzare i test con Selenium…

It’s UP to YOU!
By Stefano Trojani – All rights reserved

21
Automatizzare i test con
Selenium IDE

Grazie!
22
By Stefano Trojani – All rights reserved

Mais conteúdo relacionado

Mais procurados

Design functional solutions in Java, a practical example
Design functional solutions in Java, a practical exampleDesign functional solutions in Java, a practical example
Design functional solutions in Java, a practical exampleMarian Wamsiedel
 
Spring annotations notes
Spring annotations notesSpring annotations notes
Spring annotations notesVipul Singh
 
Data driven Automation Framework with Selenium
Data driven Automation Framework with Selenium Data driven Automation Framework with Selenium
Data driven Automation Framework with Selenium Edureka!
 
Functional Tests Automation with Robot Framework
Functional Tests Automation with Robot FrameworkFunctional Tests Automation with Robot Framework
Functional Tests Automation with Robot Frameworklaurent bristiel
 
Introduction to Robot Framework (external)
Introduction to Robot Framework (external)Introduction to Robot Framework (external)
Introduction to Robot Framework (external)Zhe Li
 
자동화된 Test Case의 효과
자동화된 Test Case의 효과자동화된 Test Case의 효과
자동화된 Test Case의 효과도형 임
 
Understanding Unit Testing
Understanding Unit TestingUnderstanding Unit Testing
Understanding Unit Testingikhwanhayat
 
RoR (Ruby on Rails)
RoR (Ruby on Rails)RoR (Ruby on Rails)
RoR (Ruby on Rails)scandiweb
 
Data Driven Testing
Data Driven TestingData Driven Testing
Data Driven TestingMaveryx
 
Class object method constructors in java
Class object method constructors in javaClass object method constructors in java
Class object method constructors in javaRaja Sekhar
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Seleniumvivek_prahlad
 
Coding Best Practices
Coding Best PracticesCoding Best Practices
Coding Best Practicesmh_azad
 

Mais procurados (20)

Selenium
SeleniumSelenium
Selenium
 
Design functional solutions in Java, a practical example
Design functional solutions in Java, a practical exampleDesign functional solutions in Java, a practical example
Design functional solutions in Java, a practical example
 
Spring annotations notes
Spring annotations notesSpring annotations notes
Spring annotations notes
 
Data driven Automation Framework with Selenium
Data driven Automation Framework with Selenium Data driven Automation Framework with Selenium
Data driven Automation Framework with Selenium
 
Unit Test
Unit TestUnit Test
Unit Test
 
JDBC
JDBCJDBC
JDBC
 
Gradle
GradleGradle
Gradle
 
Functional Tests Automation with Robot Framework
Functional Tests Automation with Robot FrameworkFunctional Tests Automation with Robot Framework
Functional Tests Automation with Robot Framework
 
Introduction to Robot Framework (external)
Introduction to Robot Framework (external)Introduction to Robot Framework (external)
Introduction to Robot Framework (external)
 
Test Complete
Test CompleteTest Complete
Test Complete
 
자동화된 Test Case의 효과
자동화된 Test Case의 효과자동화된 Test Case의 효과
자동화된 Test Case의 효과
 
Understanding Unit Testing
Understanding Unit TestingUnderstanding Unit Testing
Understanding Unit Testing
 
RoR (Ruby on Rails)
RoR (Ruby on Rails)RoR (Ruby on Rails)
RoR (Ruby on Rails)
 
Data Driven Testing
Data Driven TestingData Driven Testing
Data Driven Testing
 
Java interface
Java interfaceJava interface
Java interface
 
Class object method constructors in java
Class object method constructors in javaClass object method constructors in java
Class object method constructors in java
 
Selenium Primer
Selenium PrimerSelenium Primer
Selenium Primer
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Selenium
 
testng
testngtestng
testng
 
Coding Best Practices
Coding Best PracticesCoding Best Practices
Coding Best Practices
 

Destaque

Creare Suite di Test Automatici intelligenti con Selenium IDE
Creare Suite di Test Automatici intelligenti con Selenium IDECreare Suite di Test Automatici intelligenti con Selenium IDE
Creare Suite di Test Automatici intelligenti con Selenium IDEStefano Trojani
 
Come utilizzare la PEC nella vita di tutti i giorni al massimo delle sue pote...
Come utilizzare la PEC nella vita di tutti i giorni al massimo delle sue pote...Come utilizzare la PEC nella vita di tutti i giorni al massimo delle sue pote...
Come utilizzare la PEC nella vita di tutti i giorni al massimo delle sue pote...Stefano Trojani
 
Eseguire più suite di test automatici insieme con Selenium IDE - Evolve Today!
Eseguire più suite di test automatici insieme con Selenium IDE - Evolve Today! Eseguire più suite di test automatici insieme con Selenium IDE - Evolve Today!
Eseguire più suite di test automatici insieme con Selenium IDE - Evolve Today! Stefano Trojani
 
Presentazione Testing automatizzato
Presentazione Testing automatizzatoPresentazione Testing automatizzato
Presentazione Testing automatizzatoangelolu
 
Agile Testing e UX: come ottenere il massimo da QA e Design
Agile Testing e UX: come ottenere il massimo da QA e DesignAgile Testing e UX: come ottenere il massimo da QA e Design
Agile Testing e UX: come ottenere il massimo da QA e DesignStefano Trojani
 
Qualità del Software
Qualità del SoftwareQualità del Software
Qualità del SoftwareYeser Rema
 
Agile Testing: Come Scrivere Use Case
Agile Testing: Come Scrivere Use CaseAgile Testing: Come Scrivere Use Case
Agile Testing: Come Scrivere Use CaseStefano Trojani
 
Android Test Automation – one year later
Android Test Automation – one year laterAndroid Test Automation – one year later
Android Test Automation – one year laterDominik Dary
 
Appium: Automation for Mobile Apps
Appium: Automation for Mobile AppsAppium: Automation for Mobile Apps
Appium: Automation for Mobile AppsSauce Labs
 
Mobile-First SEO - The Marketers Edition #3XEDigital
Mobile-First SEO - The Marketers Edition #3XEDigitalMobile-First SEO - The Marketers Edition #3XEDigital
Mobile-First SEO - The Marketers Edition #3XEDigitalAleyda Solís
 

Destaque (11)

Creare Suite di Test Automatici intelligenti con Selenium IDE
Creare Suite di Test Automatici intelligenti con Selenium IDECreare Suite di Test Automatici intelligenti con Selenium IDE
Creare Suite di Test Automatici intelligenti con Selenium IDE
 
Come utilizzare la PEC nella vita di tutti i giorni al massimo delle sue pote...
Come utilizzare la PEC nella vita di tutti i giorni al massimo delle sue pote...Come utilizzare la PEC nella vita di tutti i giorni al massimo delle sue pote...
Come utilizzare la PEC nella vita di tutti i giorni al massimo delle sue pote...
 
Eseguire più suite di test automatici insieme con Selenium IDE - Evolve Today!
Eseguire più suite di test automatici insieme con Selenium IDE - Evolve Today! Eseguire più suite di test automatici insieme con Selenium IDE - Evolve Today!
Eseguire più suite di test automatici insieme con Selenium IDE - Evolve Today!
 
Presentazione Testing automatizzato
Presentazione Testing automatizzatoPresentazione Testing automatizzato
Presentazione Testing automatizzato
 
Agile Testing e UX: come ottenere il massimo da QA e Design
Agile Testing e UX: come ottenere il massimo da QA e DesignAgile Testing e UX: come ottenere il massimo da QA e Design
Agile Testing e UX: come ottenere il massimo da QA e Design
 
Qualità del Software
Qualità del SoftwareQualità del Software
Qualità del Software
 
Agile Testing: Come Scrivere Use Case
Agile Testing: Come Scrivere Use CaseAgile Testing: Come Scrivere Use Case
Agile Testing: Come Scrivere Use Case
 
Nikto
NiktoNikto
Nikto
 
Android Test Automation – one year later
Android Test Automation – one year laterAndroid Test Automation – one year later
Android Test Automation – one year later
 
Appium: Automation for Mobile Apps
Appium: Automation for Mobile AppsAppium: Automation for Mobile Apps
Appium: Automation for Mobile Apps
 
Mobile-First SEO - The Marketers Edition #3XEDigital
Mobile-First SEO - The Marketers Edition #3XEDigitalMobile-First SEO - The Marketers Edition #3XEDigital
Mobile-First SEO - The Marketers Edition #3XEDigital
 

Semelhante a Come automatizzare i test con Selenium IDE

Tech Webinar: Test e2e per AngularJS e non solo
Tech Webinar: Test e2e per AngularJS e non soloTech Webinar: Test e2e per AngularJS e non solo
Tech Webinar: Test e2e per AngularJS e non soloCodemotion
 
Chatting with windows phone 8 : Speech API
Chatting with windows phone 8 : Speech API Chatting with windows phone 8 : Speech API
Chatting with windows phone 8 : Speech API Massimo Bonanni
 
PASS Virtual Chapter - SQL Server Continuous Integration
PASS Virtual Chapter - SQL Server Continuous IntegrationPASS Virtual Chapter - SQL Server Continuous Integration
PASS Virtual Chapter - SQL Server Continuous IntegrationAlessandro Alpi
 
CONTINUOUS INTEGRATION CON SQL SERVER
CONTINUOUS INTEGRATION CON SQL SERVERCONTINUOUS INTEGRATION CON SQL SERVER
CONTINUOUS INTEGRATION CON SQL SERVERDotNetCampus
 
DotNetCampus - Continuous Integration con Sql Server
DotNetCampus - Continuous Integration con Sql ServerDotNetCampus - Continuous Integration con Sql Server
DotNetCampus - Continuous Integration con Sql ServerAlessandro Alpi
 
DevOpsHeroes 2016 - Realizzare Continouous Integration con SQL Server e Visua...
DevOpsHeroes 2016 - Realizzare Continouous Integration con SQL Server e Visua...DevOpsHeroes 2016 - Realizzare Continouous Integration con SQL Server e Visua...
DevOpsHeroes 2016 - Realizzare Continouous Integration con SQL Server e Visua...Alessandro Alpi
 
Mocking Objects Practices
Mocking Objects PracticesMocking Objects Practices
Mocking Objects PracticesGrUSP
 
Alessandro Forte - Realizzare controlli Ajax in ASP.Net
Alessandro Forte - Realizzare controlli Ajax in ASP.NetAlessandro Forte - Realizzare controlli Ajax in ASP.Net
Alessandro Forte - Realizzare controlli Ajax in ASP.NetAlessandro Forte
 
Il buon programmatore - consigli pratici per una vita felice
Il buon programmatore - consigli pratici per una vita feliceIl buon programmatore - consigli pratici per una vita felice
Il buon programmatore - consigli pratici per una vita feliceAndrea Dottor
 
Software Testing & Test Driven Development
Software Testing & Test Driven DevelopmentSoftware Testing & Test Driven Development
Software Testing & Test Driven DevelopmentSergio Santoro
 
Java Unit Testing - Introduction
Java Unit Testing - IntroductionJava Unit Testing - Introduction
Java Unit Testing - Introductionfgianneschi
 
Toscana Joomla Party - Proteggiamo il nostro sito Joomla!
Toscana Joomla Party - Proteggiamo il  nostro sito Joomla!Toscana Joomla Party - Proteggiamo il  nostro sito Joomla!
Toscana Joomla Party - Proteggiamo il nostro sito Joomla!Paolo Nuti
 
Malware Analysis. A Case Study
Malware Analysis. A Case StudyMalware Analysis. A Case Study
Malware Analysis. A Case StudyGianni Amato
 

Semelhante a Come automatizzare i test con Selenium IDE (20)

Tech Webinar: Test e2e per AngularJS e non solo
Tech Webinar: Test e2e per AngularJS e non soloTech Webinar: Test e2e per AngularJS e non solo
Tech Webinar: Test e2e per AngularJS e non solo
 
Build Automation Tips
Build Automation TipsBuild Automation Tips
Build Automation Tips
 
TTT - Test, Tools and Tips - jug roma
TTT - Test, Tools and Tips - jug romaTTT - Test, Tools and Tips - jug roma
TTT - Test, Tools and Tips - jug roma
 
Chatting with windows phone 8 : Speech API
Chatting with windows phone 8 : Speech API Chatting with windows phone 8 : Speech API
Chatting with windows phone 8 : Speech API
 
Java lezione 13
Java lezione 13Java lezione 13
Java lezione 13
 
Java introduzione
Java introduzioneJava introduzione
Java introduzione
 
PASS Virtual Chapter - SQL Server Continuous Integration
PASS Virtual Chapter - SQL Server Continuous IntegrationPASS Virtual Chapter - SQL Server Continuous Integration
PASS Virtual Chapter - SQL Server Continuous Integration
 
CONTINUOUS INTEGRATION CON SQL SERVER
CONTINUOUS INTEGRATION CON SQL SERVERCONTINUOUS INTEGRATION CON SQL SERVER
CONTINUOUS INTEGRATION CON SQL SERVER
 
DotNetCampus - Continuous Integration con Sql Server
DotNetCampus - Continuous Integration con Sql ServerDotNetCampus - Continuous Integration con Sql Server
DotNetCampus - Continuous Integration con Sql Server
 
DevOpsHeroes 2016 - Realizzare Continouous Integration con SQL Server e Visua...
DevOpsHeroes 2016 - Realizzare Continouous Integration con SQL Server e Visua...DevOpsHeroes 2016 - Realizzare Continouous Integration con SQL Server e Visua...
DevOpsHeroes 2016 - Realizzare Continouous Integration con SQL Server e Visua...
 
Mocking Objects Practices
Mocking Objects PracticesMocking Objects Practices
Mocking Objects Practices
 
Alessandro Forte - Realizzare controlli Ajax in ASP.Net
Alessandro Forte - Realizzare controlli Ajax in ASP.NetAlessandro Forte - Realizzare controlli Ajax in ASP.Net
Alessandro Forte - Realizzare controlli Ajax in ASP.Net
 
Il buon programmatore - consigli pratici per una vita felice
Il buon programmatore - consigli pratici per una vita feliceIl buon programmatore - consigli pratici per una vita felice
Il buon programmatore - consigli pratici per una vita felice
 
Owasp parte1-rel1.1
Owasp parte1-rel1.1Owasp parte1-rel1.1
Owasp parte1-rel1.1
 
Software Testing & Test Driven Development
Software Testing & Test Driven DevelopmentSoftware Testing & Test Driven Development
Software Testing & Test Driven Development
 
Java Unit Testing - Introduction
Java Unit Testing - IntroductionJava Unit Testing - Introduction
Java Unit Testing - Introduction
 
Tfs Basic - Quick Intro
Tfs Basic - Quick IntroTfs Basic - Quick Intro
Tfs Basic - Quick Intro
 
#dd12 grillo daniele_xpages_tips_tricks_rev2
#dd12 grillo daniele_xpages_tips_tricks_rev2#dd12 grillo daniele_xpages_tips_tricks_rev2
#dd12 grillo daniele_xpages_tips_tricks_rev2
 
Toscana Joomla Party - Proteggiamo il nostro sito Joomla!
Toscana Joomla Party - Proteggiamo il  nostro sito Joomla!Toscana Joomla Party - Proteggiamo il  nostro sito Joomla!
Toscana Joomla Party - Proteggiamo il nostro sito Joomla!
 
Malware Analysis. A Case Study
Malware Analysis. A Case StudyMalware Analysis. A Case Study
Malware Analysis. A Case Study
 

Mais de Stefano Trojani

Attiva le mail su Register.it e configurale su Mobile
Attiva le mail su Register.it e configurale su MobileAttiva le mail su Register.it e configurale su Mobile
Attiva le mail su Register.it e configurale su MobileStefano Trojani
 
Come inviare email e newsletter senza farle finire nello SPAM
Come inviare email e newsletter  senza farle finire nello SPAMCome inviare email e newsletter  senza farle finire nello SPAM
Come inviare email e newsletter senza farle finire nello SPAMStefano Trojani
 
What Personas are why and how to use them
What Personas are why and how to use themWhat Personas are why and how to use them
What Personas are why and how to use themStefano Trojani
 
Scenari di utilizzo di una mail con Active Sync (Exchange)
Scenari di utilizzo di una mail con Active Sync (Exchange)Scenari di utilizzo di una mail con Active Sync (Exchange)
Scenari di utilizzo di una mail con Active Sync (Exchange)Stefano Trojani
 
Plant UML come creare Grafici UML in modo facile
Plant UML come creare Grafici UML in modo facilePlant UML come creare Grafici UML in modo facile
Plant UML come creare Grafici UML in modo facileStefano Trojani
 
Webinar sull'utilizzo dell'Active Sync dell'email professional
Webinar sull'utilizzo dell'Active Sync dell'email professionalWebinar sull'utilizzo dell'Active Sync dell'email professional
Webinar sull'utilizzo dell'Active Sync dell'email professionalStefano Trojani
 
Street Fight between Open Exchange vs. Office 365
Street Fight between Open Exchange vs. Office 365Street Fight between Open Exchange vs. Office 365
Street Fight between Open Exchange vs. Office 365Stefano Trojani
 
Manuale di migrazione account Exchange 2003 su account Exchange di Office365 ...
Manuale di migrazione account Exchange 2003 su account Exchange di Office365 ...Manuale di migrazione account Exchange 2003 su account Exchange di Office365 ...
Manuale di migrazione account Exchange 2003 su account Exchange di Office365 ...Stefano Trojani
 
Breve Storia della Street Photography
Breve Storia della Street PhotographyBreve Storia della Street Photography
Breve Storia della Street PhotographyStefano Trojani
 
Webinar sul Funzionamento della nuova mail/PIM di Register.it
Webinar sul Funzionamento della nuova mail/PIM di Register.itWebinar sul Funzionamento della nuova mail/PIM di Register.it
Webinar sul Funzionamento della nuova mail/PIM di Register.itStefano Trojani
 
Cosa sono le Personas e perchè usarle
Cosa sono le Personas e perchè usarleCosa sono le Personas e perchè usarle
Cosa sono le Personas e perchè usarleStefano Trojani
 
Webinar sulla PEC del Gestore Register.it
Webinar sulla PEC del Gestore Register.itWebinar sulla PEC del Gestore Register.it
Webinar sulla PEC del Gestore Register.itStefano Trojani
 

Mais de Stefano Trojani (12)

Attiva le mail su Register.it e configurale su Mobile
Attiva le mail su Register.it e configurale su MobileAttiva le mail su Register.it e configurale su Mobile
Attiva le mail su Register.it e configurale su Mobile
 
Come inviare email e newsletter senza farle finire nello SPAM
Come inviare email e newsletter  senza farle finire nello SPAMCome inviare email e newsletter  senza farle finire nello SPAM
Come inviare email e newsletter senza farle finire nello SPAM
 
What Personas are why and how to use them
What Personas are why and how to use themWhat Personas are why and how to use them
What Personas are why and how to use them
 
Scenari di utilizzo di una mail con Active Sync (Exchange)
Scenari di utilizzo di una mail con Active Sync (Exchange)Scenari di utilizzo di una mail con Active Sync (Exchange)
Scenari di utilizzo di una mail con Active Sync (Exchange)
 
Plant UML come creare Grafici UML in modo facile
Plant UML come creare Grafici UML in modo facilePlant UML come creare Grafici UML in modo facile
Plant UML come creare Grafici UML in modo facile
 
Webinar sull'utilizzo dell'Active Sync dell'email professional
Webinar sull'utilizzo dell'Active Sync dell'email professionalWebinar sull'utilizzo dell'Active Sync dell'email professional
Webinar sull'utilizzo dell'Active Sync dell'email professional
 
Street Fight between Open Exchange vs. Office 365
Street Fight between Open Exchange vs. Office 365Street Fight between Open Exchange vs. Office 365
Street Fight between Open Exchange vs. Office 365
 
Manuale di migrazione account Exchange 2003 su account Exchange di Office365 ...
Manuale di migrazione account Exchange 2003 su account Exchange di Office365 ...Manuale di migrazione account Exchange 2003 su account Exchange di Office365 ...
Manuale di migrazione account Exchange 2003 su account Exchange di Office365 ...
 
Breve Storia della Street Photography
Breve Storia della Street PhotographyBreve Storia della Street Photography
Breve Storia della Street Photography
 
Webinar sul Funzionamento della nuova mail/PIM di Register.it
Webinar sul Funzionamento della nuova mail/PIM di Register.itWebinar sul Funzionamento della nuova mail/PIM di Register.it
Webinar sul Funzionamento della nuova mail/PIM di Register.it
 
Cosa sono le Personas e perchè usarle
Cosa sono le Personas e perchè usarleCosa sono le Personas e perchè usarle
Cosa sono le Personas e perchè usarle
 
Webinar sulla PEC del Gestore Register.it
Webinar sulla PEC del Gestore Register.itWebinar sulla PEC del Gestore Register.it
Webinar sulla PEC del Gestore Register.it
 

Come automatizzare i test con Selenium IDE

  • 1. Agile Testing Automatizzare i test con Selenium IDE di Stefano Trojani By Stefano Trojani 1
  • 2. Automatizzare i test con Selenium IDE Cosa è Selenium IDE 2 By Stefano Trojani – All rights reserved
  • 3. Automatizzare i test con Selenium IDE Cos’è Selenium IDE Selenium è software di automazione dei test Web Based Open Source Selenium è un tool che supporta il rapido sviluppo di test automatici web-based Selenium funziona ovunque sia supportato il javascritp (quindi es: non dentro il flash) Selenium può essere agganciato a altri linguaggio come: java, php, ruby, python… Selenium scrive Test Cases usando differenti linguaggi tra cui l’HTML 3 By Stefano Trojani – All rights reserved
  • 4. Automatizzare i test con Selenium IDE I vantaggi nell’uso di Selenium IDE Selenium IDE è gratis Selenium IDE è facile da installare come plugin di Mozilla Firefox Selenium IDE può creare Test Case in modo molto facile (semplicemente «registrando» la navigazione nel browser) Selenium IDE può essere usato in modo più «puntuale» investigando il codice (es: con firebug) per identificare dei blocci di codice univoci da richiamare 4 By Stefano Trojani – All rights reserved
  • 5. Automatizzare i test con Selenium IDE Installare Selenium IDE 1) Selenium può essere installato semplicemente usando il Browser Firefox e scaricando IDE dalla pagina del sito SeleniumHQ http://www.seleniumhq.org/download/ 2) Selezionare “Install Now” 3) Una volta installato sarà necessario riavviare il Browser 5 By Stefano Trojani – All rights reserved
  • 6. Automatizzare i test con Selenium IDE Avviare Selenium IDE Per avviare Selenium IDE basterà cliccare “opzioni” di Firefox e successivamente cliccare sull’icona corrispondente. Scorciatoia (Ctrl+Alt+S) 6 By Stefano Trojani – All rights reserved
  • 7. L’interfaccia di Selenim IDE Comandi di esecuzione Tasto “registra” Spazio dedicato ai comandi Interfaccia di inserimento comandi Finestra di Log, Reference, etc… 7 By Stefano Trojani – All rights reserved
  • 8. Automatizzare i test con Selenium IDE I comandi più usati (e semplici) AZIONE COMANDO Aprire una pagina open Cliccare un ogetto nella pagina click o clickAndWait Inserire dei valori nelle textarea (es: uno username) type Selezionare un valore da una dropdown select Salvare un variable store Verificare un contenuto della pagina verifyTextPresent 8 By Stefano Trojani – All rights reserved
  • 9. Automatizzare i test con Selenium IDE Rimbocchiamoci le maniche: Creiamo un Test Case di prova 9 By Stefano Trojani – All rights reserved
  • 10. Automatizzare i test con Selenium IDE Creazione di un Test Case di prova Proviamo adesso a creare un Test Case usando Selenium IDE sempicemente “registando” le azioni. Testeremo la Login ad una webmail su un importante sito web. La login su cui vogliamo fare il TC 10 By Stefano Trojani – All rights reserved
  • 11. Automatizzare i test con Selenium IDE «Registrazione» di un Test Case 1) Avviamo la “registazione” 2) Facciamo le operazioni sul sito web (loggiamoci) 3) Stoppiamo la registrazione La login su cui vogliamo fare il TC By Stefano Trojani – All rights reserved 11
  • 12. Automatizzare i test con Selenium IDE Esecuzione del Test Case Basterà pigiare l’icona per far rieseguire le stesse operazioni a Selenium IDE Nota: A video il browser inizierà a muoversi facendo le stesse operazioni che abbiamo registrato. 12 By Stefano Trojani – All rights reserved
  • 13. Automatizzare i test con Selenium IDE Analizziamo un po’ il codice generato…. Test Case scritto “registrando” open - http://www.webamil.sito.com selectWindow - null type - div[3]/div/div[1]/div[2]/div[2]/form/fieldset/input[1] - USERNAME Type - div[3]/div/div[1]/div[2]/div[2]/form/fieldset/input[2] - PASSWORD Select div[3]/div/div[1]/div[2]/div[2]/form/fieldset/div[2]/input - label=Open-Xchange clickAndWait - name=login Pause - 1000 Codice “sporco” es: xpath 13 By Stefano Trojani – All rights reserved
  • 14. Automatizzare i test con Selenium IDE Tre tipi di “pulizia” nel codice xpath type - div[3]/div/div[1]/div[2]/div[2]/form/fieldset/input[1] – USERNAME  Facile da usare (ci sono anche plugin) Pericoloso da manutenere (basta cambiare un tag nell’intera pagina ed il test smette di funzionare) css type - //input[@class=‘subject’] – USERNAME  abbastanza sicuro e stabile  Laborioso a identificare (meglio usare Firebug) id type – id=writer_field_to- USERNAME  Sicuro, univoco, pulito Raramente il codice delle pagine è così pulito da avere un ID per ogni oggetto By Stefano Trojani – All rights reserved 14
  • 15. Automatizzare i test con Selenium IDE Ispezioniamo il codice per migliorarlo Analizziamo un po’ il codice della pagina con Firebug https://addons.mozilla.org/enUS/firefox/addon/firebug/ E cerchiamo di identificare gli elementi nel codice per renderlo più “pulito”… 15 By Stefano Trojani – All rights reserved
  • 16. Automatizzare i test con Selenium IDE Guardiamo i “miglioramenti” del test case Test Case corretto manualmente (utilizzando firebug) open - http://www.webamil.sito.com selectWindow - null type - name=user_name - USERNAME Type - name=user_pass - PASSWORD Select - name=webmail - label=Open-Xchange clickAndWait - name=login Pause - 1000 Codice “pulito” ed univoco 16 By Stefano Trojani – All rights reserved
  • 17. Automatizzare i test con Selenium IDE Creazione di Suite E’ possibile inoltre creare delle Suite: un insieme di test case di Selenium che possono essere eseguiti tutti insieme (a cascata) semplicemente pigiando il bottone su Selenim IDE Una suite di test formata da tanti test case By Stefano Trojani – All rights reserved 17
  • 18. Automatizzare i test con Selenium IDE Allora… ho trovato il paradiso! No, ci dei limiti… 18 By Stefano Trojani – All rights reserved
  • 19. Automatizzare i test con Selenium IDE I limiti di Selenium IDE Selenium IDE funziona solo come plugin sul Browser Firefox (non è quindi possibile trstare altri browser) Selenium IDE supporta solo script scritti nel suo linguaggio proprietario (Selense) Selenium IDE incontra forti problemi nella gestione di contenuti complessi o dinamici (es: iframes, istanze javascript, ajax, codice html «sporco»…) 19 By Stefano Trojani – All rights reserved
  • 20. Automatizzare i test con Selenium IDE Rassumendo  Pregi Selenium IDE permette di testare in modo semplice (con differenti livelli di complessità che dipendono dalla conoscenza del prodotto) interfacce HTML. Possono essere gestiti molti test case raccolti in Suite ed eseguiti tutti insieme.  Svantaggi Selenium IDE funziona solo come plugin sul Browser Firefox (non è quindi possibile trstare altri browser) ed incontra forti problemi nella gestione di contenuti complessi o dinamici 20 By Stefano Trojani – All rights reserved
  • 21. Automatizzare i test con Selenium… It’s UP to YOU! By Stefano Trojani – All rights reserved 21
  • 22. Automatizzare i test con Selenium IDE Grazie! 22 By Stefano Trojani – All rights reserved