web testware evolution - semantic scholar...selenium webdriver works at html level, i.e., locates...

23
Web Testware Evolution Filippo Ricca, Maurizio Leotta, Andrea Stocco, Diego Clerissi, Paolo Tonella 15th IEEE International Symposium on Web Systems Evolution

Upload: others

Post on 23-May-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Web Testware Evolution

Filippo Ricca, Maurizio Leotta, Andrea Stocco, Diego Clerissi, Paolo Tonella

15th IEEE International Symposium on Web Systems Evolution

Page 2: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Our History

Past

Present

Future

Page 3: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Our History

Web application (site) testing

Past

Present

Future

Page 4: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Our History

Web application (site) testing

RIA testing

Past

Present

Future

Page 5: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Our History

Web application (site) testing

RIA testing

Web Testware Evolution

Past

Present

Future

Page 6: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Our History

Web application (site) testing

RIA testing

Web Testware Evolution

Robust Web Page Locators

Past

Present

Future

Page 7: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Past: Web testing (1) •  Context in 2000/2001:

–  Web applications (sites) •  Mainly static pages •  User interaction: Forms

•  Computation only server-side (ex. CGI)

–  Web Engineering: an emerging discipline • Web  master  =  graphics  +  “some”  programming  skills  • Ultra-­‐fast  life  cycle  /  frequent  changes  • No  quality  control  

Need  for  Tes*ng  prac*ces!  

Page 8: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Past: Web testing (2)

Filippo  Ricca  &  Paolo  Tonella:    Analysis  and  Tes,ng  of  Web  Applica,ons  

•  Our proposal: a technique and a tool –  Key idea: Web application test model

•  Model elements: pages, forms, frames

Page 9: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Unexpected success ...

Page 10: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Past: Ajax testing

•  Ajax: New challenge for Web testing!

•  Our proposal: a test model –  nodes = states representing DOM instances

Alessandro   MarcheGo,   Paolo   Tonella,   Filippo   Ricca:  State-­‐Based  Tes,ng  of  Ajax  Web  Applica,ons  

Paolo   Tonella,   Filippo   Ricca:   Dynamic model extraction and statistical analysis of web applications

WSE 2002

Page 11: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Present: Web Testware Evolution •  Web applications evolve at a very fast rate •  Automated Web tests are broken frequently

when a web application evolves –  Test cases are fragile!

•  Effort to repair them is substantial!

Page 12: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Web Testware Evolution: why? •  Several local companies experimented the

problem of fragile test cases and asked our help

•  Fragile test = a minimal change in the app breaks the test •  Ex. Label of a button is changed

evolution

Page 13: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Selenium WebDriver and Locators •  WebDriver provides a programming interface

–  it drives a browser natively, as a user does

•  Test cases are manually implemented –  in a programming language

•  e.g., Java, C#, Python, Ruby….

–  Selenium WebDriver commands + JUnit assertions

Selenium WebDriver works at HTML level, i.e., locates HTML

elements and interacts with them

Page 14: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Locators Example To select and click this element

We can use the following locators:

•  driver.findElement(By.id("login")).click(); •  driver.findElement(By.xpath("/html/body/form/a")).click(); •  driver.findElement(By.linkText("Login")).click();

Page 15: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Empirical results: web testware evolution

•  IDs locators are the preferred way to locate an element (when possible) –  IDs turned out to be the most robust

•  less than 2% of the 459 ID locators were broken, while 60% of the 791 XPath required to be fixed

•  But often it is not possible using IDs locators –  An alternative is using XPaths

–  Need for robust XPath expressions!

driver.findElement(By.id("login")).click();

Page 16: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Future: Robust XPath Locators

To select the director name: A1 ≡ /html/body/div[2]/table/td[2]/text()

Page 17: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Future: Robust XPath Locators

To select the director name: A1 ≡ /html/body/div[2]/table/td[2]/text()

It will break if the structure of the underlying web page changes - Ex. the first div is deleted

Page 18: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Future: Robust XPath Locators

To select the director name: A1 ≡ /html/body/div[2]/table/td[2]/text()

It will break if the structure of the underlying web page changes - Ex. the first div is deleted

A2 ≡ //div[@class=’content’]/*/td[2]/text() A3 ≡ //table[@width=’80%’]/td[2]/text()

Equivalent but less depedendent from the strucuture

Page 19: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Robust XPath Locators •  Several proposals to build robust XPaths

–  In the literature on web data extraction

•  Their robustness has never been investigated in Web testing

•  We selected Dalvi’s approach1, implemented the algorithm and applied it to web testing –  The algorithm generates expressions in top-down way, starting

from the most general XPath expression (“//*”) and specializing it by applying a number of transformations

•  Ex. Transf1_1 converts a * to a tag name

1N. Dalvi, P. Bohannon, and F. Sha. Robust web extraction: an approach based on a probabilistic tree-edit model. In SIGMOD 2009

Page 20: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Empirical Study Design •  Goal: evaluating the robustness of XPaths created

by means of Dalvi’s algorithm when the web application under test evolves

•  Context: –  Subjects: developers facing web testing –  Objects: heterogeneous OS web applications

•  Treatments: –  Absolute XPath –  FirePath XPath: relative XPaths generated by FirePath

–  Auto-XPath: XPaths generated by Dalvi’s algorithm

Page 21: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Preliminary results •  Claroline 1.10.7 (270KLOCs)

–  Learning environment allowing teachers to create and administer courses through the web

–  Open Source software based on PHP/MySQL

•  Three equivalent testsuites

•  Re-executed on version 1.11.5 (285KLOCs)

•  Results: out of 33 locators –  Absolute Xpath: 20 (60.6%)

–  FirePath Xpath: 20 (60.6%) –  Auto-Xpath: 8 (24.4%)

broken

Page 22: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

Questions?

Thanks for the attention!

Page 23: Web Testware Evolution - Semantic Scholar...Selenium WebDriver works at HTML level, i.e., locates HTML elements and interacts with them Locators Example To select and click this element

testLoginOK