The Page Object design pattern divides browser tests into three areas: the controller, where the test is created (this is a description of the test): the steps of the test, which are actions taken by the test (the steps are verbs, actions, navigation from one place to another and checking on status; and the page definitions, which are the nouns against which the steps/actions/verbs are working.
In our implementation of the Page Object pattern:
* the Cucumber feature files are the story of the tests * the steps.rb files are the verbs and actions * the page.rb files are the nouns and the pages
If you know anything about Design Patterns, you may know that they are discovered, not invented. Among people who do browser testing, the Page Object design pattern is generally accepted to be the best known solution for creating browser tests that are robust, readable, maintainable, and that will scale to large numbers of tests.
In practice, that boils down to some rules that we need to follow, and one of those rules is: *no element identifiers in steps files*. Page elements like div and span that have identifiers of e.g. class: and css: need to be managed in the page.rb files and *only* in the page.rb files.
Do not put page element identifiers into the steps of the test. This makes the tests difficult to read, difficult to scale, and very difficult to maintain.
Adhere to the Page Object design pattern: keep your page element identifiers in the /support/pages/*page.rb files ONLY, and NOT in the /step_definitions/*steps.rb files.
On Thu, Mar 20, 2014 at 11:54 PM, Chris McMahon cmcmahon@wikimedia.orgwrote:
Adhere to the Page Object design pattern: keep your page element identifiers in the /support/pages/*page.rb files ONLY, and NOT in the /step_definitions/*steps.rb files.
Is there a reason for this e-mail? Did you find a lot of violations of the pattern in the code? Since the e-mail message was sent to both QA and mobile mailing lists, my guess is that you have noticed a problem in MobileFrontend[1] repository. :)
I am not asking because I want to blame a person or a team, I think fixing such problems is a great first contribution for a new volunteer, and I am always looking for those.
Željko -- 1: https://github.com/wikimedia/mediawiki-extensions-MobileFrontend/tree/master...
On Fri, Mar 21, 2014 at 2:56 AM, Željko Filipin zfilipin@wikimedia.orgwrote:
On Thu, Mar 20, 2014 at 11:54 PM, Chris McMahon cmcmahon@wikimedia.orgwrote:
Adhere to the Page Object design pattern: keep your page element identifiers in the /support/pages/*page.rb files ONLY, and NOT in the /step_definitions/*steps.rb files.
Is there a reason for this e-mail? Did you find a lot of violations of the pattern in the code? Since the e-mail message was sent to both QA and mobile mailing lists, my guess is that you have noticed a problem in MobileFrontend[1] repository. :)
I am not asking because I want to blame a person or a team, I think fixing such problems is a great first contribution for a new volunteer, and I am always looking for those.
Right, exactly. I spent some time yesterday getting a few more MF tests to pass in Chrome and ran into several places where there are element locators in steps. Some are old, some are new. You can find them in these files in the MobileFrontend/tests/browser/features/step_definitions directory:
editor_ve_steps.rb geonotahack_steps.rb language_steps.rb mainmenu_steps.rb nearby_steps.rb
I hope to make improvements to some of these, but refactorers are welcome.
-Chris
On Fri, Mar 21, 2014 at 6:26 PM, Chris McMahon cmcmahon@wikimedia.orgwrote:
Right, exactly. I spent some time yesterday getting a few more MF tests to pass in Chrome and ran into several places where there are element locators in steps. Some are old, some are new. You can find them in these files in the MobileFrontend/tests/browser/features/step_definitions directory:
editor_ve_steps.rb geonotahack_steps.rb language_steps.rb mainmenu_steps.rb nearby_steps.rb
I hope to make improvements to some of these, but refactorers are welcome.
I have created a bug, so it does not get forgotten:
https://bugzilla.wikimedia.org/show_bug.cgi?id=63620
Željko