Code libraries for AMO pages: Difference between revisions

No edit summary
Line 1: Line 1:
== AMOlocators  ==
== AMOlocators  ==


The module groups locators into dictionaries named for a page or a list. The keys into the dictionares are mnemonics for the element it locates.  
The module groups locators into dictionaries named for a page or a list. The keys into the dictionaries are mnemonics for the element it locates.  


Benefits:  
Benefits:  
Line 9: Line 9:
*Centralize 'best practices' for locator definition and 'tricks' to address complicated situations.
*Centralize 'best practices' for locator definition and 'tricks' to address complicated situations.


=== Naming convention of dictionaries ===
The AMOlocators modules is currently in a transition to another structure.  The new structure, using nested classes, is described immedidately below.  It will expand as needed to support new scripts.  The earlier structure, using dictionaries, starts at the section "Naming convention for dictionaries".  The dictionary based locators are not expanding to more pages, but can be updated where it makes sense for a situation.  Eventually the dictionary-based locators will be removed from the module once no scripts use them.
 
=== Locators in nested classes ===
The locators are defined as simple string 'constants' in classes.  The highest level classes are page types.  Within them are classes are types of pages.  These classes have locators for individual objects and classes for groups of objects, such as add-on list.  The arrangement is intended to take advantage of autocomplete features in IDEs allowing someone to build a "path" to a locator.
 
Class names are capitalized.  Locator names are all lowercase.  The autocomplete feature in IDEs generally differentiate classes from variables with different icons.
 
An example: while editing a script in an IDE after typing "AMOlocators." (or local instance) a list classes appears containing Collections, Personas, Categories.  After selecting a classes and typing '.' another list appears for the classes within it, perhaps LandingPage, BrowsePage, SearchResults.  After selecting one of these classes a longer list appears.
 
 
=== Naming convention for dictionaries ===


...'''_List[ ]''' references elements that appear once on a list, such as headers or sort selectors.  
...'''_List[ ]''' references elements that appear once on a list, such as headers or sort selectors.  
1,072

edits