Presentation from first Selenium conference in Europe - Selenium Camp (http://seleniumcamp.com) about different test design approaches to make functional tests on Selenium more flexible, reliable and stable.
Unraveling Multimodality with Large Language Models.pdf
DSL, Page Object and Selenium – a way to reliable functional tests
1. DSL, Page Object and Selenium – a way to reliable functional tests Mikalai Alimenkou http://xpinjection.com 26.02.2011
2. Background Java Technical Lead/Scrum Master at Zoral Labs 6+ years in software development 4+ years of working by Agile methodologies Expert in Agile engineering practices Agile coach (TDD, Testing, Planning, etc.)at XP Injection (http://xpinjection.com)
10. Selenium Tests Issues: Fragile browser.click("//input[@id=(//label[text()='Fax']/@for)] "); What is going on here? browser.getText(“//div[@id='App']/div/p[4]/div[1]/h4[@class='Online']”); Depends too much on page structure!
14. Step 1: Introduce DSL Create domain-specific language for your application
15. Definition of DSL A domain-specific language (DSL) is a programming language or specification language dedicated to a particular problem domain, that is created specifically to solveproblems in this particular domain and is not intended to be able to solve problems outside it (although that may be technically possible).
18. Benefits of DSL Approach High-level – tests are in the language of product management, at the user level Readable – product management can understand them Writable – easy for developer or QA to write new test Extensible – tests base is able to grow with DSL
19. Tips and Tricks Use test class hierarchy or test helpers Use builders, visitors and other design patterns Reuse domain model from application Some common methods move to base test class Minimize usage of browser instance in tests
26. Tips and Tricks Allow chain invocations Basic page with browser details and common methods Expose only what is allowed to see or do on the page Don’t use browser instance in tests at all Use static analysis to check rules Use site map to prepare Page Objects
27. Step 3: Page Elements Divide pages on reusable elements
28. Page Consists of Elements Menu Checkbox Panel Link List of Items
34. Tellurium Basics: UI Module Groovy File Can Build Xpath in Runtime All Elements Element UID Isolated Locators Available Actions
35. Tellurium Basics: UI Object uid– unique in UI module namespace – for future extension locator – locator of the UI object A base locator (relative XPath) A composite locator (object attributes) group – applied to some kinds of UI objects to switch on grouping locating respond – define JavaScript events the UI object could respond to some basic methods – isElementPresent, isVisible, isDisabled, waitForElementPresent, getText, mouseOver, mouseOut, getAttribute
38. Tips and Tricks Create elements when first need them Review and improve elements continuously Isolate and hide hacks inside elements Use open source libraries as basis Use annotations and other metadata techniques to simplify creation
40. Long Way Bring Us to… Reliable tests Reusable test code Separation of concepts Expressive tested UI structure Short and clear tests Tests look more like acceptance tests Tests are understood by non-technical people
41. Company DSL Library Components may be reused between different applications and projects inside a company AJAX Components Company Portal Basic Components Online Store JSF Components Customer Service