SlideShare une entreprise Scribd logo
1  sur  18
Télécharger pour lire hors ligne
Automatizirano
testiranje sa
Seleniumom 2
Juraj Ćutić
Aleksander Radovan
Why testing
• Povećanje kvalitete i pouzdanosti proizvoda
• Jednostavnije održavanje
Manual or Automated?
• Ne može osigurati
100% detekciju bugova
• Može biti skupo i
dugotrajno
• Ovisi o iskustvu testera
• Može se obavljati i
tijekom builda
• Podiže moral 
• Ne može u potpunosti
zamijeniti testere
Automated testing
Illustracija od tvrtke Segue Technologies
What is Selenium
Framework za automatizirano testiranje web aplikacija
Selenium IDE – GUI za snimanje testiranja
Selenium Web Driver – API za testiranje
Selenium Grid – paralelno testiranje na više
različitih browsera
Support
Element locators
• Id - findElement(By.id("elementId"))
• Name - findElement(By.name("elementName"))
• Xpath - findElements(By.xpath("//input[@name='username']"))
• Link Text - findElement(By.linkText("linkText"))
• jQuery (DOM) - ((JavascriptExecutor)driver)
.executeScript("return $('.cheese')[0]")
• CSS - findElement(By.cssSelector("#food span.dairy.aged"))
• By: Class Name, Tag Name, Partial Link Text
Usage
Jednostavna integracija sa Junit-om ili TestNG-om i Jenkinsom
WebDriver webdriver = new FirefoxDriver();
webdriver.get("https://github.com");
List<WebElement> webElements = webdriver.findElements(By
.xpath("//ul[@class='nav logged_out']/li"));
Assert.assertEquals(5, webElements.size());
webdriver.quit();
Components
• Action builds
Actions builder = new Actions(driver);
builder.moveToElement(el).click();
builder.perform();
• Event listeners
beforeClickOn(WebElement element, WebDriver driver)
• Validacije testova (ako je false)
Assert – zaustavlja izvršavanje test
Verify - bilježi grešku u log te nastavlja izvršavati preostale akcije
Selenium Grid
Grid usage
• Potrebna je konfiguracija za svaku instancu WebDrivera
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName("firefox");
capabilities.setVersion("7");
capabilities.setPlatform("MAC");
WebDriver webdriver = new RemoteWebDriver(capabilities);
• Junit : - @RunWith(Parameterized.class) – anotacija nad klasom
- @Parameters – anotacija nad metodom u testu
• TestNG : - konfiguracija testova u XML-u
- @Parameters – anotacija nad metodom u testu
Design Pattern
Page Factory – reduciranje nepotrebnog koda
@DefaultUrl("http://www.google.com")
public class SearchPage extends PageObject {
@FindBy(id = "searchString")
@CacheLookup
WebElement searchField; ...}
Page Object :
- OOP korištenje WebDrivera
- preglednost i reduciranje nepotrebnog koda
Advantage
• Simulira realnu interakciju s browserom
• Velika podrška platformi, browsera i jezika za
implementaciju
• Isti kod moguće koristi za više različitih browsera
• Mogućnost kreiranja screenshota aplikacije u određenom
trenutku
• Open source framework
Practice
• Sporost pri učitavanju stranica u browser
• Veliki promet preko HTTP-a (slike, css ili .js fileovi)
• Aplikacija na kojoj se vrši testiranje mora biti startana
• Problemi u komunikaciji mogu uzrokovati greške u
testovima
• Izmjene u funkcionalnosti ili sučelju mogu utjecati na
ispravnost testove (potrebno je i njih editirati)
Who Uses Selenium?
Demo
Conclusion
• Automatizirano testiranje je najbolje koristiti kod
ponavljajućih i predvidljivih slijedova aktivnosti
• Ne može u potpunosti zamijeniti „ručno” testiranje
• Ne može se testirati sve
• Preporuča uvesti ga u kasnijim fazama razvoja, kad nema
jako puno velikih promjena
The end

Contenu connexe

En vedette

En vedette (19)

JavaCro'14 - Sustainability of business performance and best practices – Zlat...
JavaCro'14 - Sustainability of business performance and best practices – Zlat...JavaCro'14 - Sustainability of business performance and best practices – Zlat...
JavaCro'14 - Sustainability of business performance and best practices – Zlat...
 
JavaCro'14 - Going Digital with Java EE - Peter Pilgrim
JavaCro'14 - Going Digital with Java EE - Peter PilgrimJavaCro'14 - Going Digital with Java EE - Peter Pilgrim
JavaCro'14 - Going Digital with Java EE - Peter Pilgrim
 
JavaCro'14 - Is there a single “correct” web architecture for business apps –...
JavaCro'14 - Is there a single “correct” web architecture for business apps –...JavaCro'14 - Is there a single “correct” web architecture for business apps –...
JavaCro'14 - Is there a single “correct” web architecture for business apps –...
 
JavaCro'14 - Continuous deployment tool – Aleksandar Dostić and Emir Džaferović
JavaCro'14 - Continuous deployment tool – Aleksandar Dostić and Emir DžaferovićJavaCro'14 - Continuous deployment tool – Aleksandar Dostić and Emir Džaferović
JavaCro'14 - Continuous deployment tool – Aleksandar Dostić and Emir Džaferović
 
JavaCro'14 - GWT rebooted – Gordan Krešić
JavaCro'14 - GWT rebooted – Gordan KrešićJavaCro'14 - GWT rebooted – Gordan Krešić
JavaCro'14 - GWT rebooted – Gordan Krešić
 
JavaCro'14 - WebSockets and OpenLayers joined with Spring – Bojan Kljajin
JavaCro'14 - WebSockets and OpenLayers joined with Spring – Bojan KljajinJavaCro'14 - WebSockets and OpenLayers joined with Spring – Bojan Kljajin
JavaCro'14 - WebSockets and OpenLayers joined with Spring – Bojan Kljajin
 
JavaCro'14 - Vaadin scalability myth – Gordan Ivanović
JavaCro'14 - Vaadin scalability myth – Gordan IvanovićJavaCro'14 - Vaadin scalability myth – Gordan Ivanović
JavaCro'14 - Vaadin scalability myth – Gordan Ivanović
 
JavaCro'14 - Developing Google Chromecast applications on Android – Branimir ...
JavaCro'14 - Developing Google Chromecast applications on Android – Branimir ...JavaCro'14 - Developing Google Chromecast applications on Android – Branimir ...
JavaCro'14 - Developing Google Chromecast applications on Android – Branimir ...
 
JavaCro'14 - Securing web applications with Spring Security 3 – Fernando Redo...
JavaCro'14 - Securing web applications with Spring Security 3 – Fernando Redo...JavaCro'14 - Securing web applications with Spring Security 3 – Fernando Redo...
JavaCro'14 - Securing web applications with Spring Security 3 – Fernando Redo...
 
JavaCro'14 - Log as basis for distributed systems – Vjeran Marčinko
JavaCro'14 - Log as basis for distributed systems – Vjeran MarčinkoJavaCro'14 - Log as basis for distributed systems – Vjeran Marčinko
JavaCro'14 - Log as basis for distributed systems – Vjeran Marčinko
 
JavaCro'14 - MEAN Stack – How & When – Nenad Pećanac
JavaCro'14 - MEAN Stack – How & When – Nenad PećanacJavaCro'14 - MEAN Stack – How & When – Nenad Pećanac
JavaCro'14 - MEAN Stack – How & When – Nenad Pećanac
 
JavaCro'14 - Java in M2M technologies – Mango M2M software – Ivan Raguž
JavaCro'14 - Java in M2M technologies – Mango M2M software – Ivan RagužJavaCro'14 - Java in M2M technologies – Mango M2M software – Ivan Raguž
JavaCro'14 - Java in M2M technologies – Mango M2M software – Ivan Raguž
 
JavaCro'14 - Take Agile adoption to the next level with Integration Competenc...
JavaCro'14 - Take Agile adoption to the next level with Integration Competenc...JavaCro'14 - Take Agile adoption to the next level with Integration Competenc...
JavaCro'14 - Take Agile adoption to the next level with Integration Competenc...
 
JavaCro'14 - ZeroMQ and Java(Script) – Mladen Čikara
JavaCro'14 - ZeroMQ and Java(Script) – Mladen ČikaraJavaCro'14 - ZeroMQ and Java(Script) – Mladen Čikara
JavaCro'14 - ZeroMQ and Java(Script) – Mladen Čikara
 
JavaCro'14 - Drools Decision tables – form of human-readable rules – Dragan J...
JavaCro'14 - Drools Decision tables – form of human-readable rules – Dragan J...JavaCro'14 - Drools Decision tables – form of human-readable rules – Dragan J...
JavaCro'14 - Drools Decision tables – form of human-readable rules – Dragan J...
 
JavaCro'14 - Profile any environment with Java Flight Recorder – Johan Janssen
JavaCro'14 - Profile any environment with Java Flight Recorder – Johan JanssenJavaCro'14 - Profile any environment with Java Flight Recorder – Johan Janssen
JavaCro'14 - Profile any environment with Java Flight Recorder – Johan Janssen
 
JavaCro'14 - How to handle large amounts of data in real time using a cloud e...
JavaCro'14 - How to handle large amounts of data in real time using a cloud e...JavaCro'14 - How to handle large amounts of data in real time using a cloud e...
JavaCro'14 - How to handle large amounts of data in real time using a cloud e...
 
JavaCro'14 - Automatic database migrations – Marko Elezović
JavaCro'14 - Automatic database migrations – Marko ElezovićJavaCro'14 - Automatic database migrations – Marko Elezović
JavaCro'14 - Automatic database migrations – Marko Elezović
 
JavaCro'14 - Auditing of user activity through NoSQL database – Kristijan Duv...
JavaCro'14 - Auditing of user activity through NoSQL database – Kristijan Duv...JavaCro'14 - Auditing of user activity through NoSQL database – Kristijan Duv...
JavaCro'14 - Auditing of user activity through NoSQL database – Kristijan Duv...
 

Similaire à JavaCro'14 - Automatized testing with Selenium 2 – Juraj Ćutić and Aleksander Radovan

Napredne tehnike razvoja web aplikacija - Zend Framework
Napredne tehnike razvoja web aplikacija - Zend FrameworkNapredne tehnike razvoja web aplikacija - Zend Framework
Napredne tehnike razvoja web aplikacija - Zend FrameworkSaša Stamenković
 
Sibin Grasić - Najčešće greške WP developera
Sibin Grasić - Najčešće greške WP developeraSibin Grasić - Najčešće greške WP developera
Sibin Grasić - Najčešće greške WP developeraStartit
 
Getting bigger with flask
Getting bigger with flaskGetting bigger with flask
Getting bigger with flaskJosipKatalinic
 
Projektovanje web aplikacija
Projektovanje web aplikacijaProjektovanje web aplikacija
Projektovanje web aplikacijaDamjan Pavlica
 
Front-end development iz ugla .NET programera
Front-end development iz ugla .NET programera�Front-end development iz ugla .NET programera�
Front-end development iz ugla .NET programeraStartit
 
Vuk Nikolić - Web frontend - startap akademija, prva tech radionica
Vuk Nikolić - Web frontend - startap akademija, prva tech radionicaVuk Nikolić - Web frontend - startap akademija, prva tech radionica
Vuk Nikolić - Web frontend - startap akademija, prva tech radionicaStartap Akademija
 
Automatizacija u Front-end razvojnom procesu
Automatizacija u Front-end razvojnom procesuAutomatizacija u Front-end razvojnom procesu
Automatizacija u Front-end razvojnom procesuDalibor Gogic
 
T 4 testiranje softvera i upravljanje kvalitetom
 T 4 testiranje softvera i upravljanje kvalitetom T 4 testiranje softvera i upravljanje kvalitetom
T 4 testiranje softvera i upravljanje kvalitetomZoran Jeremic
 
SPUG Srbija - Izbegavanje prepreka kod implementacije SharePointa - Bojan Buhac
SPUG Srbija - Izbegavanje prepreka kod implementacije SharePointa - Bojan BuhacSPUG Srbija - Izbegavanje prepreka kod implementacije SharePointa - Bojan Buhac
SPUG Srbija - Izbegavanje prepreka kod implementacije SharePointa - Bojan BuhacSharePoint User Grupa Srbija
 
Izbegavanje prepreka kod implementacije SharePoint-a
Izbegavanje prepreka kod implementacije SharePoint-aIzbegavanje prepreka kod implementacije SharePoint-a
Izbegavanje prepreka kod implementacije SharePoint-aBojan Buhac
 
Testiranje projekata.pptx
Testiranje projekata.pptxTestiranje projekata.pptx
Testiranje projekata.pptxVladimirNedi
 
Primjena veb tehnologija u geografskim informacionim sistemima
Primjena veb tehnologija u geografskim informacionim sistemimaPrimjena veb tehnologija u geografskim informacionim sistemima
Primjena veb tehnologija u geografskim informacionim sistemimachiwchy
 
Studija slučaja - phishing
Studija slučaja - phishingStudija slučaja - phishing
Studija slučaja - phishingBoban Lapcevic
 
Android vs iOS development
Android vs iOS developmentAndroid vs iOS development
Android vs iOS developmentVuk Nikolić
 
P2_Modeli_Procesa.pdf
P2_Modeli_Procesa.pdfP2_Modeli_Procesa.pdf
P2_Modeli_Procesa.pdfBosnaBosnic
 

Similaire à JavaCro'14 - Automatized testing with Selenium 2 – Juraj Ćutić and Aleksander Radovan (20)

Napredne tehnike razvoja web aplikacija - Zend Framework
Napredne tehnike razvoja web aplikacija - Zend FrameworkNapredne tehnike razvoja web aplikacija - Zend Framework
Napredne tehnike razvoja web aplikacija - Zend Framework
 
Sibin Grasić - Najčešće greške WP developera
Sibin Grasić - Najčešće greške WP developeraSibin Grasić - Najčešće greške WP developera
Sibin Grasić - Najčešće greške WP developera
 
Getting bigger with flask
Getting bigger with flaskGetting bigger with flask
Getting bigger with flask
 
Projektovanje web aplikacija
Projektovanje web aplikacijaProjektovanje web aplikacija
Projektovanje web aplikacija
 
Decouple Goals
Decouple GoalsDecouple Goals
Decouple Goals
 
Front-end development iz ugla .NET programera
Front-end development iz ugla .NET programera�Front-end development iz ugla .NET programera�
Front-end development iz ugla .NET programera
 
Vuk Nikolić - Web frontend - startap akademija, prva tech radionica
Vuk Nikolić - Web frontend - startap akademija, prva tech radionicaVuk Nikolić - Web frontend - startap akademija, prva tech radionica
Vuk Nikolić - Web frontend - startap akademija, prva tech radionica
 
Automatizacija u Front-end razvojnom procesu
Automatizacija u Front-end razvojnom procesuAutomatizacija u Front-end razvojnom procesu
Automatizacija u Front-end razvojnom procesu
 
T 4 testiranje softvera i upravljanje kvalitetom
 T 4 testiranje softvera i upravljanje kvalitetom T 4 testiranje softvera i upravljanje kvalitetom
T 4 testiranje softvera i upravljanje kvalitetom
 
SPUG Srbija - Izbegavanje prepreka kod implementacije SharePointa - Bojan Buhac
SPUG Srbija - Izbegavanje prepreka kod implementacije SharePointa - Bojan BuhacSPUG Srbija - Izbegavanje prepreka kod implementacije SharePointa - Bojan Buhac
SPUG Srbija - Izbegavanje prepreka kod implementacije SharePointa - Bojan Buhac
 
Izbegavanje prepreka kod implementacije SharePoint-a
Izbegavanje prepreka kod implementacije SharePoint-aIzbegavanje prepreka kod implementacije SharePoint-a
Izbegavanje prepreka kod implementacije SharePoint-a
 
Java
JavaJava
Java
 
Testiranje projekata.pptx
Testiranje projekata.pptxTestiranje projekata.pptx
Testiranje projekata.pptx
 
Apache solr
Apache solrApache solr
Apache solr
 
Web logs: Collecting and analysing - Nikola Krgovic
Web logs: Collecting and analysing - Nikola KrgovicWeb logs: Collecting and analysing - Nikola Krgovic
Web logs: Collecting and analysing - Nikola Krgovic
 
Primjena veb tehnologija u geografskim informacionim sistemima
Primjena veb tehnologija u geografskim informacionim sistemimaPrimjena veb tehnologija u geografskim informacionim sistemima
Primjena veb tehnologija u geografskim informacionim sistemima
 
Studija slučaja - phishing
Studija slučaja - phishingStudija slučaja - phishing
Studija slučaja - phishing
 
Android vs iOS development
Android vs iOS developmentAndroid vs iOS development
Android vs iOS development
 
Java Script.ppt
Java Script.pptJava Script.ppt
Java Script.ppt
 
P2_Modeli_Procesa.pdf
P2_Modeli_Procesa.pdfP2_Modeli_Procesa.pdf
P2_Modeli_Procesa.pdf
 

Plus de HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association

Plus de HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association (20)

Java cro'21 the best tools for java developers in 2021 - hujak
Java cro'21   the best tools for java developers in 2021 - hujakJava cro'21   the best tools for java developers in 2021 - hujak
Java cro'21 the best tools for java developers in 2021 - hujak
 
JavaCro'21 - Java is Here To Stay - HUJAK Keynote
JavaCro'21 - Java is Here To Stay - HUJAK KeynoteJavaCro'21 - Java is Here To Stay - HUJAK Keynote
JavaCro'21 - Java is Here To Stay - HUJAK Keynote
 
Javantura v7 - Behaviour Driven Development with Cucumber - Ivan Lozić
Javantura v7 - Behaviour Driven Development with Cucumber - Ivan LozićJavantura v7 - Behaviour Driven Development with Cucumber - Ivan Lozić
Javantura v7 - Behaviour Driven Development with Cucumber - Ivan Lozić
 
Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...
Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...
Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...
 
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
 
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
 
Javantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander Radovan
Javantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander RadovanJavantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander Radovan
Javantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander Radovan
 
Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...
Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...
Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...
 
Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...
Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...
Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...
 
Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...
Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...
Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...
 
Javantura v6 - When remote work really works - the secrets behind successful ...
Javantura v6 - When remote work really works - the secrets behind successful ...Javantura v6 - When remote work really works - the secrets behind successful ...
Javantura v6 - When remote work really works - the secrets behind successful ...
 
Javantura v6 - Kotlin-Java Interop - Matej Vidaković
Javantura v6 - Kotlin-Java Interop - Matej VidakovićJavantura v6 - Kotlin-Java Interop - Matej Vidaković
Javantura v6 - Kotlin-Java Interop - Matej Vidaković
 
Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...
Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...
Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...
 
Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...
Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...
Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...
 
Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...
Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...
Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...
 
Javantura v6 - How can you improve the quality of your application - Ioannis ...
Javantura v6 - How can you improve the quality of your application - Ioannis ...Javantura v6 - How can you improve the quality of your application - Ioannis ...
Javantura v6 - How can you improve the quality of your application - Ioannis ...
 
Javantura v6 - Just say it v2 - Pavao Varela Petrac
Javantura v6 - Just say it v2 - Pavao Varela PetracJavantura v6 - Just say it v2 - Pavao Varela Petrac
Javantura v6 - Just say it v2 - Pavao Varela Petrac
 
Javantura v6 - Automation of web apps testing - Hrvoje Ruhek
Javantura v6 - Automation of web apps testing - Hrvoje RuhekJavantura v6 - Automation of web apps testing - Hrvoje Ruhek
Javantura v6 - Automation of web apps testing - Hrvoje Ruhek
 
Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...
Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...
Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...
 
Javantura v6 - Building IoT Middleware with Microservices - Mario Kusek
Javantura v6 - Building IoT Middleware with Microservices - Mario KusekJavantura v6 - Building IoT Middleware with Microservices - Mario Kusek
Javantura v6 - Building IoT Middleware with Microservices - Mario Kusek
 

JavaCro'14 - Automatized testing with Selenium 2 – Juraj Ćutić and Aleksander Radovan

  • 2. Why testing • Povećanje kvalitete i pouzdanosti proizvoda • Jednostavnije održavanje
  • 3. Manual or Automated? • Ne može osigurati 100% detekciju bugova • Može biti skupo i dugotrajno • Ovisi o iskustvu testera • Može se obavljati i tijekom builda • Podiže moral  • Ne može u potpunosti zamijeniti testere
  • 4. Automated testing Illustracija od tvrtke Segue Technologies
  • 5. What is Selenium Framework za automatizirano testiranje web aplikacija Selenium IDE – GUI za snimanje testiranja Selenium Web Driver – API za testiranje Selenium Grid – paralelno testiranje na više različitih browsera
  • 7. Element locators • Id - findElement(By.id("elementId")) • Name - findElement(By.name("elementName")) • Xpath - findElements(By.xpath("//input[@name='username']")) • Link Text - findElement(By.linkText("linkText")) • jQuery (DOM) - ((JavascriptExecutor)driver) .executeScript("return $('.cheese')[0]") • CSS - findElement(By.cssSelector("#food span.dairy.aged")) • By: Class Name, Tag Name, Partial Link Text
  • 8. Usage Jednostavna integracija sa Junit-om ili TestNG-om i Jenkinsom WebDriver webdriver = new FirefoxDriver(); webdriver.get("https://github.com"); List<WebElement> webElements = webdriver.findElements(By .xpath("//ul[@class='nav logged_out']/li")); Assert.assertEquals(5, webElements.size()); webdriver.quit();
  • 9. Components • Action builds Actions builder = new Actions(driver); builder.moveToElement(el).click(); builder.perform(); • Event listeners beforeClickOn(WebElement element, WebDriver driver) • Validacije testova (ako je false) Assert – zaustavlja izvršavanje test Verify - bilježi grešku u log te nastavlja izvršavati preostale akcije
  • 11. Grid usage • Potrebna je konfiguracija za svaku instancu WebDrivera DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setBrowserName("firefox"); capabilities.setVersion("7"); capabilities.setPlatform("MAC"); WebDriver webdriver = new RemoteWebDriver(capabilities); • Junit : - @RunWith(Parameterized.class) – anotacija nad klasom - @Parameters – anotacija nad metodom u testu • TestNG : - konfiguracija testova u XML-u - @Parameters – anotacija nad metodom u testu
  • 12. Design Pattern Page Factory – reduciranje nepotrebnog koda @DefaultUrl("http://www.google.com") public class SearchPage extends PageObject { @FindBy(id = "searchString") @CacheLookup WebElement searchField; ...} Page Object : - OOP korištenje WebDrivera - preglednost i reduciranje nepotrebnog koda
  • 13. Advantage • Simulira realnu interakciju s browserom • Velika podrška platformi, browsera i jezika za implementaciju • Isti kod moguće koristi za više različitih browsera • Mogućnost kreiranja screenshota aplikacije u određenom trenutku • Open source framework
  • 14. Practice • Sporost pri učitavanju stranica u browser • Veliki promet preko HTTP-a (slike, css ili .js fileovi) • Aplikacija na kojoj se vrši testiranje mora biti startana • Problemi u komunikaciji mogu uzrokovati greške u testovima • Izmjene u funkcionalnosti ili sučelju mogu utjecati na ispravnost testove (potrebno je i njih editirati)
  • 16. Demo
  • 17. Conclusion • Automatizirano testiranje je najbolje koristiti kod ponavljajućih i predvidljivih slijedova aktivnosti • Ne može u potpunosti zamijeniti „ručno” testiranje • Ne može se testirati sve • Preporuča uvesti ga u kasnijim fazama razvoja, kad nema jako puno velikih promjena