sqs.com SQS – the world’s leading specialist in software quality Please copy a slide with a suitable picture from the file „Title Slides_EN.pptx“ (change to presentation mode to download) and paste it here. If necessary, apply the correct formatting by right-clicking and choosing “Layout Title Slide“. „Title Slides_EN.pptx“ sqs.com SQS – the world’s leading specialist in software quality Chris Gormley and Mark McTaggart A Consultants Tale SQS Group Technical Services Centre (GTSC)
Schedule 2© SQS Group | A Consultants Tale | 2016 | Introductions Aim of talk What we do Common Issues in Automation Custom Element Design Code Examples Demo Q & A
What we do? 3© SQS Group | A Consultants Tale | 2016 | As test automation consultants we typically do the following. Pre-sales meeting to discuss requirements and expectations Conduct POC Conduct Health Check Make recommendations Use SQS Automation framework Enhance existing framework
Common Issues Encountered in a Selenium Framework 4© SQS Group | A Consultants Tale | 2016 | When working on automation projects we come across the following issues. Not following Development best practices DRY principles No code reusability No Coding Standards Poor commenting and documentation No Page Object Model Not using Selenium Wait methods Hardcoded data in Page Objects No Source Control No Reporting / Logging Not wrapping Selenium elements Automate too much front end
Layers of Test Automation 5© SQS Group | A Consultants Tale | 2016 | Focus on a Test Automation Pyramid Strategy GUI Tests API or Service Tests Unit Tests ROI increasing Aut Team Dev Team
Where do we go from here? 6© SQS Group | A Consultants Tale | 2016 |
Custom Element Design Overview 7© SQS Group | A Consultants Tale | 2016 | Discuss how to wrap WebElements with functionality Example of WebElement use Issues encounter with standard WebElement use What to consider before implementation Writing wrappers and base wrappers What interfaces to write and use Custom element decorators Demo Demo of test running Example wrappers discussed
Example Web Element Use © SQS Group | A Consultants Tale | 2016 |8 Above displays 2 ways to capture objects Attempt to Capture Elements and use them in a Page Object
Risks of using “WebElement” © SQS Group | A Consultants Tale | 2016 |9 Risks Readability – E.G. Element type? Naming convention? Type Safety – Risk element misuse? Code duplication – Code that interacts with element repeated throughout page objects instead of once in wrapper
Risks of using “WebElement” cont… © SQS Group | A Consultants Tale | 2016 |10 Risks Custom methods – Specialist methods that interact with element can be stored in wrapper which would not be available as standard. Inconsistent behaviour – Different element interactions? Synchronisation – Sync has to be put into Page Objects?
Prerequisites © SQS Group | A Consultants Tale | 2016 |11 Where to start? Have a test plan (Can be just a few steps in order to get going) Pick a language, IDE etc… (Whatever your test team or preferably dev team is using) Have a Selenium project set up (WebDriver, Selenium lib) The suitability of Selenium has been established Create a basic page object and test case that executes
Research is key © SQS Group | A Consultants Tale | 2016 |12 Investigate? Does the GUI use generated code? instead of etc… Do dev’s have info on how screen objects/widgets are developed? Do the objects interactions need any workarounds? E.G. Select or drop down is actually a combination of div’s Is the GUI consistently developed? E.G. A Button is the same as another
Structure © SQS Group | A Consultants Tale | 2016 |13 Design element wrappers to maximise code reuse
© SQS Group | A Consultants Tale | 2016 |14 Wrapping is a simple way to provide functionality Firstly we create an Element interface to extend some of the public Selenium interfaces.
Create Base Element Wrapper © SQS Group | A Consultants Tale | 2016 |15 Base Element Should add common Web Element standard methods Remove any methods like click, sendkeys etc… Contains custom methods that should be available for all elements Synchronisation can be added
Create a Base Element and implement shared methods © SQS Group | A Consultants Tale | 2016 |16 Following DRY (Don’t Repeat Yourself) principles we create a Base Element to cover common functionality for our Elements.
Create Element Wrappers © SQS Group | A Consultants Tale | 2016 |17 Element Wrapper (Button, Text Input etc…) Create class that extends the base element you created Add specific methods tied to the Element type Can override Base Element methods if slight variations are required Synchronisation can also be added
Create Element wrappers – Select impl © SQS Group | A Consultants Tale | 2016 |18 Above displays a good example of functionality where a workaround in Page Objects would have to be duplicated. Different implementations of the below code could also cause inconsistency.
Use of Wrapped Elements © SQS Group | A Consultants Tale | 2016 |19 Element functionality is now wrapped and can be used within a Page Object
Modify Page Factory to accept our custom Element © SQS Group | A Consultants Tale | 2016 |20 Decorates for our Element type. List decorator would be required for List. We need to write a CustomFieldDecorator that extends DefaultFieldDecorator and override decorate
What to avoid? © SQS Group | A Consultants Tale | 2016 |21 Avoid test specific methods Avoid hardcoding values where possible Over engineering, keep it simple, no need for overly complicated wrappers. E.G. Inherit common methods from a base class. No need to create multiple wrappers that do the same thing. E.G. Link, Button Exposing methods that should be hidden from wrappers. E.G. A text input having access to Click etc… Leaving Page Factory standard Forget interfaces for wrappers
What else can I do? © SQS Group | A Consultants Tale | 2016 |22 Read the WebDriver code and see what is being created, things that can be enhanced are: Custom annotations E.G. Exists or FindBy some other locator Synchronisation added by writing new findElement methods Whatever else is required for a project Write custom Element type for returning Lists
Recap © SQS Group | A Consultants Tale | 2016 |23 Create basic automation project using Page Object Model Work out what Custom Elements (Wrappers) you need Create a custom Element type to be used instead of WebElement Create BaseElement for common methods Create custom wrappers for each element and specific methods should be contained within E.G. click, setText etc… Modify Page Factory to use our new Element Don’t Repeat Yourself
sqs.com SQS – the world’s leading specialist in software quality Please copy a slide with a suitable picture from the file „Title Slides_EN.pptx“ (change to presentation mode to download) and paste it here. If necessary, apply the correct formatting by right-clicking and choosing “Layout Title Slide“. „Title Slides_EN.pptx“ sqs.com SQS – the world’s leading specialist in software quality Demo SQS Solution Center
25 Questions? © SQS Group | A Consultants Tale | 2016 |
sqs.com SQS USA Inc Bond Street, Suite 100 Naperville, IL 60563, USA Phone: Fax: Thank you for your attention. SQS Belfast The Concourse Northern Ireland Science Park Belfast BT3 9DT
Appendix A - SQS Automation Services 27© SQS Group | A Consultants Tale | 2016 | SQS Ireland has developed a range of competencies and supporting services for open source test automation
Appendix B - SQS Automation Framework 28© SQS Group | A Consultants Tale | 2016 | The SQS Automation Framework is designed to be modular TESTNG TESTING FRAMEWORK SELENIUM CHROME APPLICATION SELENIUM GRID FireFox IE SQS LIBRARIES SQS LIBRARIES REPORTING (ReportNG) XML HANDLING FILE HANDLING DB FUNCTIONS DATA HANDLING JBEHAVE BDD SOLUTION PhantomJS APPIUM ANDROID iOS STORIES / STEPS PAGE OBJECTS WRAPPERS (incl. MOBILE) CUCUMBER ALLURE REPORTING IDE REST MAVEN REST API