352
edits
(adding TBD's) |
|||
| Line 12: | Line 12: | ||
* [http://www.cheat-sheets.org/saved-copy/Locators_table_1_0_2.pdf Locator Cheat Sheet] | * [http://www.cheat-sheets.org/saved-copy/Locators_table_1_0_2.pdf Locator Cheat Sheet] | ||
= | = Concepts to Remember = | ||
== File Headers == | == File Headers == | ||
| Line 61: | Line 61: | ||
* There should be no whitespace at the end of the file (as per PEP8). | * There should be no whitespace at the end of the file (as per PEP8). | ||
* Comments should be on the line above. Remember to update comments when changing code so that code matches the comments. | * Comments should be on the line above. Remember to update comments when changing code so that code matches the comments. | ||
* Comments should be used carefully. Try not to put comments that don't provide any additional value | |||
* Class names should be in Pascal style as this is Python idiomatic. | * Class names should be in Pascal style as this is Python idiomatic. | ||
| Line 71: | Line 72: | ||
</source> | </source> | ||
= Page Objects = | == Page Objects == | ||
TBD - jlorenzo | TBD - jlorenzo | ||
* where to call marionette's APIs | |||
* why a page class shouldn't import data from the test | |||
== General == | == General == | ||
* All page objects should inherit from <code>Page</code> in page.py. | * All page objects should inherit from <code>Page</code> in page.py. | ||
| Line 81: | Line 84: | ||
* Methods should have a single purpose. | * Methods should have a single purpose. | ||
== | == Limited use of conditionals == | ||
* 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. | * 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. | ||
| Line 98: | Line 101: | ||
== Locators == | == Locators == | ||
TBD - jlorenzo | |||
* Locator variables should be prefixed with <code>_</code> to show that it is [http://docs.python.org/tutorial/classes.html#private-variables private]. | * Locator variables should be prefixed with <code>_</code> 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. | ||
| Line 146: | Line 150: | ||
== Advanced: Page Regions == | == Advanced: Page Regions == | ||
TBD - jlorenzo | |||
* How to deal with stale root_elements | |||
In some circumstances, for example where a header/navigation is common across the website, we will use a page region. The page region is a child class of the base Page object, which is inherited by all page objects. This means that the navigation can be reached from any page object and herein lies the DRY! | In some circumstances, for example where a header/navigation is common across the website, we will use a page region. The page region is a child class of the base Page object, which is inherited by all page objects. This means that the navigation can be reached from any page object and herein lies the DRY! | ||
| Line 187: | Line 193: | ||
== Assertions == | == Assertions == | ||
TBD - jlorenzo | |||
* Tests should handle the asserts -- not the page objects. | * Tests should handle the asserts -- not the page objects. | ||
* Tests should use Python's native [https://docs.python.org/2/reference/simple_stmts.html#the-assert-statement assert] statement. | * Tests should use Python's native [https://docs.python.org/2/reference/simple_stmts.html#the-assert-statement assert] statement. | ||
| Line 200: | Line 206: | ||
assert a == 'expected result' | assert a == 'expected result' | ||
</source> | </source> | ||
== Avoid sleep() calls == | |||
TBD - njpark | |||
== Use testvars.json instead of hardcoded variables == | |||
TBD - njpark | |||
== Handling shadow DOM == | |||
TBD - njpark | |||
== Switching frames and system frame == | |||
TBD - mwargers | |||
== Handling browser instances == | |||
TBD - mwargers | |||
== How to use GaiaHeader and GaiaBinaryControl == | |||
TBD - jlorenzo | |||
== How to create filename strings == | |||
TBD - njpark | |||
http://mxr.mozilla.org/gaia/source/tests/python/gaia-ui-tests/gaiatest/apps/settings/app.py#296 | |||
== Meaningful custom Assert() messages == | |||
TBD - njpark | |||
https://bugzilla.mozilla.org/show_bug.cgi?id=1198449#c2 | |||
== Returning the page object after completing an action == | |||
TBD - njpark | |||
When writing methods that is doing some action on the device, for instance opening an app or opening a subpage, make sure that the resulting action is finished and return the object of the resulting action, e.g. the app or the subpage (PageRegion) | |||
== app.py and regions/helper.py == | |||
TBD - njpark | |||
== Clean up afterwards == | |||
TBD - njpark | |||
== Avoid code duplication == | |||
TBD - jlorenzo | |||
* Use parameterized() | |||
* Centralize workarounds | |||
== Using high-level methods == | |||
TBD - jlorenzo | |||
* In a test, make sure to only have steps that are high level (for instance: messages.send_an_sms_to_yourself() instead of detailing every single tap and click) | |||
== Variable naming == | |||
TBD - jlorenzo | |||
* Name your variables with units. For example: timeout_in_seconds, width_in_pixels | |||
* Don't shorten variable names. A bad example: self.t_out_err_tim = 1000 instead of self.time_out_error_time | |||
== Simulate end-user check == | |||
TBD - jlorenzo | |||
* Check what an end-user would check. | |||
== Making test multi-locale == | |||
TBD - njpark | |||
* we check the raw text in order to verify the input from the user (for instance a phone number put in the dialer, we verify it appears in the call log) | |||
* we test the l10n-id for any string that comes from Gaia only (like an error message) | |||
== Be aware of outside consumers of ui-test == | |||
TBD - mwargers | |||
* Be aware if you change the Gaia UI test API, that outside consumers (mtbf, etc) might get broken | |||
= Submitting and Reviewing Patches = | = Submitting and Reviewing Patches = | ||
edits