Confirmed users
2,197
edits
| Line 67: | Line 67: | ||
* Single quotes (') should be used instead of double (") throughout. | * Single quotes (') should be used instead of double (") throughout. | ||
* Methods should have a single purpose | * Methods should have a single purpose | ||
== Logic == | |||
* Methods should not contain logic that depends on properties of the page. The logic and expectations should be within the test, and adding this to the page object could guard your tests against genuine failures. | |||
<pre class="brush:py;toolbar:false;"> | |||
# Good | |||
def click_login(self) | |||
self.selenium.find_element(*self._login_locator).click() | |||
# Bad | |||
def click_login(self) | |||
if not self.is_user_logged_in: | |||
self.selenium.find_element(*self._login_locator).click() | |||
else: | |||
pass | |||
</pre> | |||
== Locators == | == Locators == | ||
| Line 115: | Line 130: | ||
def report_length(length) | def report_length(length) | ||
</pre> | </pre> | ||
* Actions should wait for the appropriate action to complete. This could be an implicit or explicit wait. For example, clicking a login button might explicitly wait for a username field to be visible. | |||
== Advanced: Page Regions == | == Advanced: Page Regions == | ||