SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

The complete getting started guide to birt reporting 1 (1)
The complete getting started guide to birt reporting 1 (1)The complete getting started guide to birt reporting 1 (1)
The complete getting started guide to birt reporting 1 (1)
arkslideshareacc
 
Continuous integration with teamcity
Continuous integration with teamcityContinuous integration with teamcity
Continuous integration with teamcity
Eugene Sheretov
 
Code Coverage Revised : EclEmma on JaCoCo
Code Coverage Revised : EclEmma on JaCoCoCode Coverage Revised : EclEmma on JaCoCo
Code Coverage Revised : EclEmma on JaCoCo
Evgeny Mandrikov
 

Was ist angesagt? (20)

Given When Then
Given When ThenGiven When Then
Given When Then
 
Test Automation Pyramid
Test Automation PyramidTest Automation Pyramid
Test Automation Pyramid
 
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드katalon studio 툴을 이용한 GUI 테스트 자동화 가이드
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드
 
Spring Data JDBC: Beyond the Obvious
Spring Data JDBC: Beyond the ObviousSpring Data JDBC: Beyond the Obvious
Spring Data JDBC: Beyond the Obvious
 
Cloud Native Java GraalVM 이상과 현실
Cloud Native Java GraalVM 이상과 현실Cloud Native Java GraalVM 이상과 현실
Cloud Native Java GraalVM 이상과 현실
 
Selenium Page Object Model Using Page Factory | Selenium Tutorial For Beginne...
Selenium Page Object Model Using Page Factory | Selenium Tutorial For Beginne...Selenium Page Object Model Using Page Factory | Selenium Tutorial For Beginne...
Selenium Page Object Model Using Page Factory | Selenium Tutorial For Beginne...
 
Serverless with Google Cloud Functions
Serverless with Google Cloud FunctionsServerless with Google Cloud Functions
Serverless with Google Cloud Functions
 
Unit Testing with Jest
Unit Testing with JestUnit Testing with Jest
Unit Testing with Jest
 
REST API testing with SpecFlow
REST API testing with SpecFlowREST API testing with SpecFlow
REST API testing with SpecFlow
 
Debugging in visual studio (basic level)
Debugging in visual studio (basic level)Debugging in visual studio (basic level)
Debugging in visual studio (basic level)
 
Local Dev on Virtual Machines - Vagrant, VirtualBox and Ansible
Local Dev on Virtual Machines - Vagrant, VirtualBox and AnsibleLocal Dev on Virtual Machines - Vagrant, VirtualBox and Ansible
Local Dev on Virtual Machines - Vagrant, VirtualBox and Ansible
 
The complete getting started guide to birt reporting 1 (1)
The complete getting started guide to birt reporting 1 (1)The complete getting started guide to birt reporting 1 (1)
The complete getting started guide to birt reporting 1 (1)
 
TESTLINK INTEGRATOR
TESTLINK INTEGRATORTESTLINK INTEGRATOR
TESTLINK INTEGRATOR
 
Selenium
SeleniumSelenium
Selenium
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium  Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium
 
Continuous integration with teamcity
Continuous integration with teamcityContinuous integration with teamcity
Continuous integration with teamcity
 
Code Coverage Revised : EclEmma on JaCoCo
Code Coverage Revised : EclEmma on JaCoCoCode Coverage Revised : EclEmma on JaCoCo
Code Coverage Revised : EclEmma on JaCoCo
 
Integrating microservices with apache camel on kubernetes
Integrating microservices with apache camel on kubernetesIntegrating microservices with apache camel on kubernetes
Integrating microservices with apache camel on kubernetes
 
Qt test framework
Qt test frameworkQt test framework
Qt test framework
 
Selenium topic 1- Selenium Basic
Selenium topic 1-  Selenium BasicSelenium topic 1-  Selenium Basic
Selenium topic 1- Selenium Basic
 

Andere mochten auch

Qualità del Software
Qualità del SoftwareQualità del Software
Qualità del Software
Yeser Rema
 

Andere mochten auch (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
 

Ähnlich wie Come automatizzare i test con Selenium IDE

Malware Analysis. A Case Study
Malware Analysis. A Case StudyMalware Analysis. A Case Study
Malware Analysis. A Case Study
Gianni Amato
 

Ähnlich wie 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
 

Mehr von Stefano Trojani

Mehr von 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