| || |
Page object pattern and class member properties?
Just wondering what the convention is, I did Google search for page objects (with regards to Selenium) and didn't find what I was looking for.
Most of the tutorials, presentations, examples seem to point to use of methods only.
Here's my question, for page objects, assume same design / convention as Java classes. A class has properties and methods. With respect to that, a page as object/class, then would have certain features or descriptions (i.e. properties) and certain behaviors or actions (i.e. methods).
In a "base" page, the basic properties of a page can be (or that it has the following):
* (HTML) source
* (body) text
with that in mind, a page object class can (or should) expose these properties (say with get accessor methods in Java, no need to set as they're mainly read-only), such as:
rather than using an all methods based approach of
So far, I haven't found an example yet, describing use of properties for page objects, most just show methods. Should we not use properties as well? Or people just seem to have left that out in the examples?
Re: Page object pattern and class member properties?
Actually, sorry for post. Possibly my mistake, get confused when you work with and know multiple languages.
getPropertyName() is generally an accessor method in Java. Too bad not as nice as .NET/C# accessor methods of get/set, which allow you to actually do
page.title instead of page.getTitle(), with title actually referring to something else like driver.getTitle() rather than a member variable named title that is part of page class.
and I guess those tutorials make sense about this as they're mainly in Java, hence you wouldn't see the C# example of the get/set accessor methods.
But it would apply for those implementing page objects in .NET/C#, and perhaps dynamically typed languages.