property of Tierra and is not to be disclosed without the written consent of Tierra. No part of this publication may be reproduced or transmitted in any form or by any means including electronic storage, reproduction, execution or transmission without the prior written consent of Tierra. The recipient of this document by its retention and use agrees to respect the security status of the information contained herein. This document is intended for limited circulation. The information contained in this document is subject to change without notice and should not be construed as a commitment by Tierra unless such commitment is expressly given in a covering document. PYTHON PYTEST SELENIUM SPLINTER 2017/04/08 Floren ce ROBUST UI TESTS
of testing pyramid!!) • Flaky (unless you adopt some robustness techniques) • Hard to maintain when application changes (unless you adopt a Page Object Model pattern and parametrized selectors) • On fail, it’s hard to detect if it is a real problem and which is the affected component So: • Don’t write too many GUI tests! But • If you are working on legacy front end applications you might consider to increase a bit the GUI based tests coverage if it’s hard to write tests con UI components (not optimal) UI tests
OO programming to your web pages under test • Support for selenium waits (avoid sleeps and networking issues) • Organize your page in component and subcomponents (regions) • Support for dynamic regions (eg: list of CRUD items) • Delegate logics on regions • Add on your page object class selectors as class attributes • Add on your page object class methods • Divide et conquera approach If you are using Python: • PyPOM (Mozilla) is your friend (http://pypom.readthedocs.io/en/latest/) • Supports both selenium and splinter (https://splinter.readthedocs.io/en/latest/)
= ‘QA-’ • listing_region.filter() # show only QA- items • listing_region.items[-1].delete() • for item in listing_region.items[0:2:]: item.delete().confirm() • listing_region.items[0].name == ‘QA-043...’ Regions and dynamic regions
for dealing with page with forms or CMS-like web applications • Declarative way (based on colander - http://docs.pylonsproject.org/projects/colander/en/latest/) • You declare your edit form schema describing your form composition (for each form item you specify the field name, field type and widget) What pypom_form does: • Provides an easy way to set or retrieve the form field value • Provides API for fine grained interaction with the underlying widget Basically pypom_form hides complexity and makes interation with UI element easy! PyPOM for form tests: pypom_form!
the widget root • No more long list of selectors on page object class • Great way to deal with complex widgets (like list of dictionary data or datetimes). It makes hard things easier • If you provide the implementation for all your application widgets for your CMS- form based like application, you will speed up your testing process. Productivity increases! • Clearner code on Page Object model classes, only business logic methods! • pypom_form widgets are regions, automatic waits before interacting with the widget (eg: load time, fields depending on other fields and so on) pypom_form benefits
reusable widget library • Tests runs against different skins with 100% code reuse (thanks to pytest’s fixtures parametrization, no test case duplication!) • Testers in Tierra with no programming skills are able to write automated tests if widgets are already available with a basic training • We are using Python, Pytest and pytest-bdd even for NON python software because... Python rocks! In addition: • Automated and declarative test data creation on demand (support for manual testing) • Easy way to setup complex preconditions in a data/keyword driven testing approach manner on BDD if you need more fine grained testa • High reusability of components, create your widget collections and become FAST! pypom_form in Tierra
for any question, let’s discuss together about testing! • Ping me on @davidemoro If you liked it: • GitHub star and share • Spread the word! • Let’s collaborate, it’s free software!
disclosed herein is the exclusive property of Tierra and is not to be disclosed without the written consent of Tierra. No part of this publication may be reproduced or transmitted in any form or by any means including electronic storage, reproduction, execution or transmission without the prior written consent of Tierra. The recipient of this document by its retention and use agrees to respect the security status of the information contained herein. This document is intended for limited circulation. The information contained in this document is subject to change without notice and should not be construed as a commitment by Tierra unless such commitment is expressly given in a covering document. [email protected] m @davidemoro