Clustering-Aided Page Object Generation for Web Testing

  • Andrea StoccoEmail author
  • Maurizio Leotta
  • Filippo Ricca
  • Paolo Tonella
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9671)


To decouple test code from web page details, web testers adopt the Page Object design pattern. Page objects are facade classes abstracting the internals of web pages (e.g., form fields) into high-level business functions that can be invoked by test cases (e.g., user authentication). However, writing such page objects requires substantial effort, which is paid off only later, during software evolution. In this paper we propose a clustering-based approach for the identification of meaningful abstractions that are automatically turned into Java page objects. Our clustering approach to page object identification has been integrated into our tool for automated page object generation, Apogen. Experimental results indicate that the clustering approach provides clusters of web pages close to those manually produced by a human (with, on average, only three differences per web application). 75 % of the code generated by Apogen can be used as-is by web testers, breaking down the manual effort for page object creation. Moreover, a large portion (84 %) of the page object methods created automatically to support assertion definition corresponds to useful behavioural abstractions.


Test Script Document Object Model Page Object Login Credential Getter Method 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


  1. 1.
    Arthur, D., Vassilvitskii, S.: K-means++: the advantages of careful seeding. In: Proceedings of SODA, pp. 1027–1035. Society for Industrial and Applied Mathematics (2007)Google Scholar
  2. 2.
    Blanco, L., Dalvi, N., Machanavajjhala, A.: Highly efficient algorithms for structural clustering of large websites. In: Proceedings of WWW, pp. 437–446 (2011)Google Scholar
  3. 3.
    Choudhary, S.R., Prasad, M.R., Orso, A.: Crosscheck: combining crawling and differencing to better detect cross-browser incompatibilities in web applications. In: Proceedings of ICST, pp. 171–180 (2012)Google Scholar
  4. 4.
    Choudhary, S.R., Versee, H., Orso, A.: Webdiff: automated identification of cross-browser issues in web applications. In: Proceedings of ICSM, pp. 1–10 (2010)Google Scholar
  5. 5.
    Crescenzi, V., Merialdo, P., Missier, P.: Clustering web pages based on their structure. Data Knowl. Eng. 54(3), 279–299 (2005)CrossRefGoogle Scholar
  6. 6.
    Kaufman, L., Rousseeuw, P.: Clustering by means of medoids. In: Statistical Data Analysis Based on the L1-Norm and Related Methods, pp. 405–416. North-Holland (1987)Google Scholar
  7. 7.
    Kaufman, L., Rousseeuw, P.J.: Finding Groups in Data: An Introduction to Cluster Analysis. Wiley Series in Probability and Mathematical Statistics. Wiley, Hoboken (1990)CrossRefGoogle Scholar
  8. 8.
    Kuhn, H.W.: The hungarian method for the assignment problem. Naval Res. Logistics Q. 2, 83–97 (1955)MathSciNetCrossRefzbMATHGoogle Scholar
  9. 9.
    Leotta, M., Clerissi, D., Ricca, F., Tonella, P.: Capture-replay vs. programmable web testing: an empirical assessment during test case evolution. In: Proceedings of 20th Working Conference on Reverse Engineering, WCRE 2013, pp. 272–281. IEEE (2013)Google Scholar
  10. 10.
    Leotta, D., Clerissi, D., Ricca, F., Tonella, P.: Approaches and tools for automated end-to-end web testing. Adv. Comput. 101, 193–237 (2016)CrossRefGoogle Scholar
  11. 11.
    Leotta, M., Stocco, A., Ricca, F., Tonella, P.: Automated generation of visual web tests from DOM-based web tests. In: Proceedings of 30th ACM/SIGAPP Symposium on Applied Computing, SAC 2015, pp. 775–782. ACM (2015)Google Scholar
  12. 12.
    Leotta, M., Stocco, A., Ricca, F., Tonella, P.: Meta-heuristic generation of robust XPath locators for web testing. In: Proceedings of 8th IEEE/ACM International Workshop on Search-Based Software Testing, SBST 2015, pp. 36–39. IEEE (2015)Google Scholar
  13. 13.
    Leotta, M., Stocco, A., Ricca, F., Tonella, P.: Using multi-locators to increase the robustness of web test cases. In: Proceedings of 8th IEEE International Conference on Software Testing, Verification and Validation, ICST 2015, pp. 1–10. IEEE (2015)Google Scholar
  14. 14.
    Leotta, M., Stocco, A., Ricca, F., Tonella, P.: ROBULA+: an algorithm for generating robust XPath locators for web testing. J. Softw. Evol. Process 28(3), 177–204 (2016)CrossRefGoogle Scholar
  15. 15.
    Levenshtein, V.: Binary codes capable of correcting deletions, insertions and reversals. Sov. Phys. Dokl. 10, 707 (1966)MathSciNetzbMATHGoogle Scholar
  16. 16.
    Mesbah, A., Prasad, M.R.: Automated cross-browser compatibility testing. In: Proceedings of ICSE, pp. 561–570. ACM (2011)Google Scholar
  17. 17.
    Mesbah, A., van Deursen, A., Lenselink, S.: Crawling ajax-based web applications through dynamic analysis of user interface state changes. TWEB 6(1), 3:1–3:30 (2012)CrossRefGoogle Scholar
  18. 18.
    Ocariza, F., Bajaj, K., Pattabiraman, K., Mesbah, A.: An empirical study of client-side JavaScript bugs. In: Proceedings of ESEM, pp. 55–64. IEEE Computer Society (2013)Google Scholar
  19. 19.
    Pawlik, M., Augsten, N.: Efficient computation of the tree edit distance. ACM Trans. Database Syst. 40(1), 3:1–3:40 (2015)MathSciNetCrossRefGoogle Scholar
  20. 20.
    Ricca, F., Pianta, E., Tonella, P., Girardi, C.: Improving web site understanding with keyword-based clustering. J. Softw. Maintenance 20(1), 1–29 (2008)CrossRefGoogle Scholar
  21. 21.
    Ricca, F., Tonella, P.: Detecting anomaly and failure in web applications. IEEE Multimedia 13(2), 44–51 (2006)CrossRefGoogle Scholar
  22. 22.
    Rousseeuw, P.: Silhouettes: a graphical aid to the interpretation and validation of cluster analysis. J. Comput. Appl. Math. 20(1), 53–65 (1987)CrossRefzbMATHGoogle Scholar
  23. 23.
    Sampath, S.: Advances in user-session-based testing of web applications. Adv. Comput. 86, 87–108 (2012)CrossRefGoogle Scholar
  24. 24.
    Stocco, A., Leotta, M., Ricca, F., Tonella, P.: APOGEN: automatic page object generator for web testing. Softw. Qual. J. (under review)Google Scholar
  25. 25.
    Stocco, A., Leotta, M., Ricca, F., Tonella, P.: Why creating web page objects manually if it can be done automatically? In: Proceedings of 10th IEEE/ACM International Workshop on Automation of Software Test, AST 2015, pp. 70–74. IEEE (2015)Google Scholar
  26. 26.
    Tombros, A., Ali, Z.: Factors affecting web page similarity. In: Losada, D.E., Fernández-Luna, J.M. (eds.) ECIR 2005. LNCS, vol. 3408, pp. 487–501. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  27. 27.
    Tonella, P., Ricca, F., Marchetto, A.: Recent advances in web testing. Adv. Comput. 93, 1–51 (2014)CrossRefGoogle Scholar
  28. 28.
    Tonella, P., Ricca, F., Pianta, E., Girardi, C.: Evaluation methods for web application clustering. In: Proceedings of WSE, pp. 33–40. IEEE (2003)Google Scholar
  29. 29.
    van Deursen, A.: Testing web applications with state objects. Commun. ACM 58(8), 36–43 (2015)CrossRefGoogle Scholar
  30. 30.
    Witten, I.H., Frank, E., Hall, M.A.: Data Mining: Practical Machine Learning Tools and Techniques, 3rd edn. Morgan Kaufmann Publishers Inc., San Francisco (2011)Google Scholar
  31. 31.
    Wohlin, C., Runeson, P., Höst, M., Ohlsson, M.C., Regnell, B.: Experimentation in Software Engineering. Springer, Heidelberg (2012)CrossRefzbMATHGoogle Scholar

Copyright information

© Springer International Publishing Switzerland 2016

Authors and Affiliations

  • Andrea Stocco
    • 1
    Email author
  • Maurizio Leotta
    • 1
  • Filippo Ricca
    • 1
  • Paolo Tonella
    • 2
  1. 1.DIBRIS – Università di GenovaGenovaItaly
  2. 2.Fondazione Bruno KesslerTrentoItaly

Personalised recommendations