Tip and tricks for building a Cucumber BDD web/mobile automation framework
- Start with Happy Path and then diverge
- Use reusable steps
- Use more declarative steps (leave details for step defs)
- Describe the WHAT, not the HOW
- Scenarios should be reusable on different devices, browsers etc.
- Use imperative fluent Domain Specific Language in step definitions
- Don’t hardcode anything, use modelling classes
- Think about your Data Model (Customer)
- Thing about your Page Domain (use Page Model)
- Assert a lot of stuff here (in your “should” assertion steps)
- This is where the models interact with each other (keep it abstract)
- Data Domain
- Page Domain
- Driver Domain
- A domain class is like an API
- A data model class has only attributes, it’s a view layer
- Use OOP (inheritance etc.)
- Use factories (builders) for creating different test data
- Use Page and Component Model design
- A page is a class in itself and has attributes (web elements) and actions with these attributes
- If a page gets too big, create sub components
- Also, create reusable components (for forms, drop downs, header, footer etc.)
- Use OOP here (Main Page etc., abstract, interfaces for web/mobile)
- Use Finders to interact with elements
- This is where you customize your web driver that you use to interact with Pages
- Things like User Agent, Screen Sizes, Browser Types are all handled in here
- Finders
- Helpers
- etc.
- This is where you customize your browser interactions into more human readable generic methods
- Eg: searchByInnerText(), searchWithTimeout(), fillAllFormFields(), scrollIntoMiddle(), hoverOver() etc.
- Mix-up javascript, jquery, selenium etc. into easy methods
- You reuse finders in all other Pages
- Helper methods to randomize data, sort, filter, deal with time, dates, databases, anything you can imagine
- Scenario tests should be agnostic to: Browser, Screen Sizes, Environments, Data types
- For this use configuration and resources files and create different running config profiles
- Folder structure and naming should be relevant eg: LoginFeature, LoginSteps, LoginPage, login() method
- Once you have implemented your first step, RUN IT IN A PIPELINE!!!