QA/Execution/Web Testing/Docs/Automation/StyleGuide: Difference between revisions

Jump to navigation Jump to search
Line 30: Line 30:
==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
*Each Page should be grouped within one module
*If using mutliple words to describe a module separate them with underscores '_'
    test_search.py
*timeout time should be taken from vars.py


    Page Objects should not do asserts. This should be done within the test
*Locators Class Variables
**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
**Suffix of _locator


    Each Page should be grouped within one module
*Accessing Locator Variables
 
**Accessing Locators should be done through a property method as this keeps the locator as readonly.
    If using mutliple words to describe a module separate them with underscores '_'
 
 
    timeout time should be taken from vars.py
 
Locators Class Variables
 
    Locator variables should be prefixed with _ to show that it is "private"(http://docs.python.org/tutorial/classes.html#private-variables)
 
    Variables should be descriptive of the area and not clash with any properties
 
    Suffix of _locator?
 
Accessing Locator Variables
 
    Accessing Locators should be done through a property method as this keeps the locator as readonly.
 
   
     @property
     @property
     def search_box(self):
     def search_box(self):
         return self.search_box_locator
         return self.search_box_locator
          
          
 
*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.


     @property
     @property
     def page_title(self):
     def page_title(self):
         return self.selenium.get_title()
         return self.selenium.get_title()
Action methods


    Methods that perform actions on the page should indicate the action in the method name
*Action methods
**Methods that perform actions on the page should indicate the action in the method name


     GOOD: def click_report_with_length(length)
     GOOD: def click_report_with_length(length)
     BAD: def report_length(length)
     BAD: def report_length(length)


Confirmed users
753

edits

Navigation menu