Confirmed users
2,197
edits
Line 37: | Line 37: | ||
</pre> | </pre> | ||
==Page Object Style Guide== | == Page Object Style Guide == | ||
* All Page Objects should inherit from Page in page.py | |||
*All Page Objects should inherit from Page in page.py | * Page Objects should not do asserts. This should be done within the test | ||
*Page Objects should not do asserts. This should be done within the test | * Each Page should be grouped within one module | ||
*Each Page should be grouped within one module | * If using mutliple words to describe a module separate them with underscores '_' | ||
*If using mutliple words to describe a module separate them with underscores '_' | |||
test_search.py | test_search.py | ||
* | * Timeout time should be taken from conftest.py | ||
* Locators Class Variables | |||
*Locators Class Variables | ** Locator variables should be prefixed with _ to show that it is "[http://docs.python.org/tutorial/classes.html#private-variables private]" | ||
**Locator variables should be prefixed with _ to show that it is "[http://docs.python.org/tutorial/classes.html#private-variables private]" | ** Variables should be descriptive of the area and not clash with any properties | ||
**Variables should be descriptive of the area and not clash with any properties | ** Suffix of _locator | ||
**Suffix of _locator | * Accessing Locator Variables | ||
** Accessing Locators should be done through a property method as this keeps the locator as readonly. | |||
*Accessing Locator Variables | |||
**Accessing Locators should be done through a property method as this keeps the locator as readonly. | |||
<pre class="brush:py;toolbar:false;"> | <pre class="brush:py;toolbar:false;"> | ||
@property | @property | ||
Line 59: | Line 55: | ||
return self.search_box_locator | return self.search_box_locator | ||
</pre> | </pre> | ||
* This approach can also be used with get_* calls with Selenium making it more idiomatic for the call. | |||
*This approach can also be used with get_* calls with Selenium making it more idiomatic for the call. | |||
<pre class="brush:py;toolbar:false;"> | <pre class="brush:py;toolbar:false;"> | ||
@property | @property | ||
Line 67: | Line 61: | ||
return self.selenium.get_title() | return self.selenium.get_title() | ||
</pre> | </pre> | ||
* Action methods | |||
*Action methods | ** Methods that perform actions on the page should indicate the action in the method name | ||
**Methods that perform actions on the page should indicate the action in the method name | |||
<pre class="brush:py;toolbar:false;"> | <pre class="brush:py;toolbar:false;"> | ||
# Good | # Good |