Code libraries for AMO pages: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
 
(21 intermediate revisions by the same user not shown)
Line 1: Line 1:
== AMOlocators ==  
== Summary of libraries ==
The module groups locators into dictionaries named for a page or list. The dictionaries' indexes are mnemonics for the element it locates.
*[[AMOlocators]] contains Xpath locators for elements on AMO pages.
<blockquote>
Purpose:
*Provide scripts writers a quick reference for time-consuming process of establishing a working locator.  
*Changes to web pages which could break many scripts could be resolved by updating the module.
*Centralize 'best practices' for locator definition and 'tricks' to address complicated situations.
</blockquote>


Benefits:
*[[AMOfunctions]] contains functions for elements specific to AMO pages.
* Provide scripts writers a quick substitute for time-comsuming process of establishing a working locator.
* Changes to web pages which break many scripts could be resolved by updating the module.
* Centralize 'best practices' for locator definition and 'tricks' to addressing complicated situation.
 
Naming convention
 
...'''_List[ ]''' reference elements that appear once on a list, such as headers or sort selectors. 
 
...'''_List['item']''' references the item node on the list ''without'' an index, unlike the _List_Item[ ] locators described below.  Could be used with an is_element_present to check if a list contains any items.
<br>Suitable for: get_xpath_count()
<br>Example: itemCount = sel.get_xpath_count ( AMOlocators.addonBrowsePage''_List['item']'' ). 
 
...'''_List['sortOption']'''
<br>Suitable for: select()
<br>Example: sel.select ( AMOlocators.addonBrowsePage''_List['sortOption']'', value='name' )
 
...'''_List_Item[ ]''' references elements on a particular item in a list.  In the locator the item node is followed by [%s] and must be followed by ''% indexVar'' where ''indexVar'' has the index of the item in the list.
<br>Suitable for: get_text(), get_attribute()
<br>Example 1: addonName = get_text( addonBrowsePage_''List_Item['name']'' % idx ) retrieves the text for the add-on's name on the ''idx''-th item in the list.
<br> example 2: addonHref = sel.get_attribute ( AMOlocator.addonCategoryLandingPage_TopRated''List_Item['link']'' % idx + "@href" ) retrieves the href attribute on the link element for the idx-th item on the Top Rated list on the add-on category landing page.
 
...[*Link] refer to links suitable for click( ).  ex: sel.click( AMOlocator.addonBrowsePage_List_Item[detailLink] % idx ) clicks on the detail page link for the idx-th add-on listed in the browse page.  example 2: sel.click( AMOlocator.addonCategoryLandingPage_TopRatedList['ViewAlllink'] ) clicks on the View All link at the bottom of the Top Rated list on the category landing page.
 
...[*Select] refers to select controls for select( ).  ex: sel.select( AMO_locators.addonsSearchResults['sortSelect'], 'value=' + sortOption) selects from the add-ons search results page the sort option with the 'value' attribute specified by sortOption.
 
== AMOfunctions ==
 
This is intended as a summary of functions.  Refer to the in-line function doc regarding parameters and other information.
 
login - login to a generic user.  The parameter is mnenomic for the user type.
 
submitHeaderSearch - supplies data to the search panel in the AMO header and submits the search.  Only the selenium instance (sel) parameter is required, and other parameter are named and optional.  The script does not return the search results, rather it returns one of three strings:
null string - at least one item was returned in the search results based on locators defined in AMOlocators.  itself.
'no results' - the 'No Result Found' message was returned, based on locators defined in AMOlocators
'unexpected layout' - neither of the above conditions were detected using is_element_present( ) and locators for search results page.
 
 
getAdminFeaturedList - returns a dictionary of featured items from the admin control panel.  Items are qualified by the application and feature type (ex: extensions, persona) specified by the parameters.  The parameter values are the corresponding values found in the admin featured items list.  See the in-line function doc for more information on the structure of the dictionary that is returned.
 
isUserURL - returns True if the parameter is the format of a user profile URL, otherwise False.
 
getAddonIdFromURL - returns the add-on id segment of a URL for an add-on
 
userURLpattern - returns the pattern for a user profile URL.  defined as a function to allow more extendability.
 
userURLpatternGroup - returns the pattern for a user profile URL with id in a grouping to allow parsing URL id.  defined as a function.
 
isAddonURL - returns True if the parameter is the format of a add-on URL, otherwise False.
 
addonURLpattern - returns the pattern for a add-on URL.  defined as a function to allow more extendability.
 
addonURLpatternGroup - returns the pattern for a add-on URL with id in a grouping to allow parsing add-on id.  defined as a function.
 
verifyStarsRating - confirms the stars rating elements are in agreement within the locator specified by the parameter.  returns a list of strings describing the exceptions found, or an empty list if no exceptions are found.

Latest revision as of 01:12, 10 April 2010

Summary of libraries

  • AMOlocators contains Xpath locators for elements on AMO pages.

Purpose:

  • Provide scripts writers a quick reference for time-consuming process of establishing a working locator.
  • Changes to web pages which could break many scripts could be resolved by updating the module.
  • Centralize 'best practices' for locator definition and 'tricks' to address complicated situations.
  • AMOfunctions contains functions for elements specific to AMO pages.