Paul Grandjean – Lithia Motors Inc / Driveway.com
Cypress is the new, easy to use, end-to-end automation tool and Selenium is the hard to assemble, old grandmaster. The Cypress developers strongly suggest not to use page objects but rather use ‘application actions’ (custom functions) instead. With Selenium test suites, page objects are a must. But is this truly a valid recommendation for large test suites? The Cypress community presents a very useful technique for test setup, but they neglect the primary reasons for using page objects in the first place, efficient code maintenance. I believe the best practice is to use both techniques. And they are not mutually exclusive by any means. They can complement each other well. We use page objects within the Cypress tests themselves for reducing duplicated code, managing the element locators, and writing easy to read tests. But for test setups, application actions as the Cypress community recommends may be the better technique for improving test performance, and eliminating dependencies on parts of the application that are also under test. This paper discusses the strengths and weaknesses of both techniques and when to use each for effective Cypress test suites.