The best part about using properties files, or XML files, or JSON files, or ... is that non-programmers can adjust tests to changing circumstances (e.g., simple text changes in the app, relocation of elements). The worst part is that the programmers who are the only ones who can understand the test logic don’t have immediate access to the details that bind the app to the test (e.g., locators, important text). Even worse are the anti-patterns that result in the same element details existing in multiple properties/XML/whatever files – as an old colleague used to say, “data in two places is wrong in at least one”.
As to schools, it’s the fallacy of approaching test automation from the automated-manual-test world. Systems like QTP and its ilk love their “object repositories”, which are just gussied-up spreadsheets, and trainers with manual-QA and QTP-automated backgrounds see those spreadsheets as good ideas. But if you start from a programming background, you never wind up there. Those repositories/spreadsheets are what another old colleague used to call “Worst Practices”.
Ross
There was a really good concrete discussion of implanting the PageObject pattern back in June 2011: https://groups.google.com/forum/?fromgroups=#!topic/selenium-users/QYEC5-clH_k It has a number of real-world examples from folks who have actually done this stuff. You might find it useful.
Ross
From: seleniu...@googlegroups.com [mailto:seleniu...@googlegroups.com] On Behalf Of carina0110
Sent: Thursday, November 01, 2012 5:24 PM
To: seleniu...@googlegroups.com
Subject: [selenium-users] Re: Advantages/Disadvantages of separating elements from behavior vs keep together in page object class
I'm probably not wording it correctly. It's here in the US I'm referring to. Here's how they're doing it: A page object class is created to store the methods applicable to a specific application page and a page elements class is created with the elements for that same page such that the elements are in one class and the behavior in another class for the same page.
This sounds like an anti-pattern to me. Object-oriented programming, of which the PageObject pattern is a variation, usually leads you to combine both data and related operations into a single class, and often to hide a lot of the data from other classes as a result.
“Dynamic” elements are a red herring. What most people mean when they call an element “dynamic” is that it is created at run-time by some piece of code and doesn’t have certain predictable characteristics that make it easy to identify. I’d say every element described as “dynamic” merely have an unpredictable ID= attribute, and have plenty of other predictable characteristics that can be used to locate them. In fact, if they don’t, you’re not going to be able to automate them at all, because you can’t tell a program how to find them. You can handle these “dynamic” elements just fine with any style of coding, whether it’s split-data-and-method, straight-line-test-code, external-spreadsheet-of-locators, or something else entirely.
Ross
From: seleniu...@googlegroups.com [mailto:seleniu...@googlegroups.com] On Behalf Of carina0110
Sent: Thursday, November 01, 2012 5:24 PM
To: seleniu...@googlegroups.com
Subject: [selenium-users] Re: Advantages/Disadvantages of separating elements from behavior vs keep together in page object class
I'm probably not wording it correctly. It's here in the US I'm referring to. Here's how they're doing it: A page object class is created to store the methods applicable to a specific application page and a page elements class is created with the elements for that same page such that the elements are in one class and the behavior in another class for the same page.