B2G/gecko/testing/marionette/marionette-elements.js
/**
   * Helper method to find. Finds all element using find's criteria
   * 
   * @param string using
   *        String identifying which search method to use
   * @param string value
   *        Value to look for
   * @param nsIDOMElement rootNode
   *        Document root
   * @param nsIDOMElement startNode
   *        Node from which we start searching
   *
   * @return nsIDOMElement
   *        Returns found elements or throws Exception if not found
   */
Helper method to find. Finds all element using find's criteria

@param string using
String identifying which search method to use
@param string value
Value to look for
@param nsIDOMElement rootNode
Document root
@param nsIDOMElement startNode
Node from which we start searching

@return nsIDOMElement
Returns found elements or throws Exception if not found
Helper method to find . Finds all element using find ' s criteria @param string using String identifying which search method to use @param string value Value to look for @param nsIDOMElement rootNode Document root @param nsIDOMElement startNode Node from which we start searching @return nsIDOMElement Returns found elements or throws Exception if not found
function EM_findElements(using, value, rootNode, startNode) {
    let elements = [];
    switch (using) {
      case ID:
        value = './/*[@id="' + value + '"]';
      case XPATH:
        elements = this.findByXPathAll(rootNode, value, startNode);
        break;
      case NAME:
        elements = startNode.getElementsByName ?
                   startNode.getElementsByName(value) : 
                   this.findByXPathAll(rootNode, './/*[@name="' + value + '"]', startNode);
        break;
      case CLASS_NAME:
        elements = startNode.getElementsByClassName(value);
        break;
      case TAG:
        elements = startNode.getElementsByTagName(value);
        break;
      case LINK_TEXT:
      case PARTIAL_LINK_TEXT:
        let allLinks = rootNode.getElementsByTagName('A');
        for (let i = 0; i < allLinks.length; i++) {
          let text = allLinks[i].text;
          if (PARTIAL_LINK_TEXT == using) {
            if (text.indexOf(value) != -1) {
              elements.push(allLinks[i]);
            }
          } else if (text == value) {
            elements.push(allLinks[i]);
          }
        }
        break;
      case SELECTOR:
        elements = Array.slice(startNode.querySelectorAll(value));
        break;
      default:
        throw new ElementException("No such strategy", 500, null);
    }
    return elements;
  }
function EM_findElements ( using , value , rootNode , startNode ) { let elements = [ ] ; switch ( using ) { case ID : value = './/*[@id="' + value + '"]' ; case XPATH : elements = this . findByXPathAll ( rootNode , value , startNode ) ; break ; case NAME : elements = startNode . getElementsByName ? startNode . getElementsByName ( value ) : this . findByXPathAll ( rootNode , './/*[@name="' + value + '"]' , startNode ) ; break ; case CLASS_NAME : elements = startNode . getElementsByClassName ( value ) ; break ; case TAG : elements = startNode . getElementsByTagName ( value ) ; break ; case LINK_TEXT : case PARTIAL_LINK_TEXT : let allLinks = rootNode . getElementsByTagName ( 'A' ) ; for ( let i = 0 ; i < allLinks . length ; i ++ ) { let text = allLinks [ i ] . text ; if ( PARTIAL_LINK_TEXT == using ) { if ( text . indexOf ( value ) != - 1 ) { elements . push ( allLinks [ i ] ) ; } } else if ( text == value ) { elements . push ( allLinks [ i ] ) ; } } break ; case SELECTOR : elements = Array . slice ( startNode . querySelectorAll ( value ) ) ; break ; default : throw new ElementException ( "No such strategy" , 500 , null ) ; } return elements ; }
Helper method to find.
Helper method to find .