Execute a block of code within a given scope. If `locator` begins with
 `/` or `./`, then it's assumed to be an XPath selector; otherwise, it's
 assumed to be a CSS selector.
257
def scope_within(locator)
      if locator
        # Use the selector_for method if it's defined. This may be provided
        # by features/support/selectors.rb, generated by cucumber-rails.
        if defined? selector_for
          kelp_within(*selector_for(locator)) { yield }
        # Otherwise, fall back on the Capybara locator syntax (CSS or XPath)
        else
          if locator =~ /\.?\//
            kelp_within(:xpath, locator) { yield }
          else
            kelp_within(:css, locator) { yield }
          end
        end
      else
        yield
      end
    end
736503
function(selector) {
            selector = selector || '';
            selector = Selector._replaceShorthand(Y.Lang.trim(selector)); 
            var token = Selector._getToken(),     // one token per simple selector (left selector holds combinator)
                query = selector, // original query for debug report
                tokens = [],    // array of tokens
                found = false,  // whether or not any matches were found this pass
                match,         // the regex match
                test,
                i, parser;

            /*
                Search for selector patterns, store, and strip them from the selector string
                until no patterns match (invalid selector) or we run out of chars.

                Multiple attributes and pseudos are allowed, in any order.
                for example:
                    'form:first-child[type=button]:not(button)[lang|=en]'
            */
            outer:
            do {
                found = false; // reset after full pass
                for (i = 0; (parser = Selector._parsers[i++]);) {
                    if ( (match = parser.re.exec(selector)) ) { // note assignment
                        if (parser.name !== COMBINATOR ) {
                            token.selector = selector;
                        }
                        selector = selector.replace(match[0], ''); // strip current match from selector
                        if (!selector.length) {
                            token.last = true;
                        }

                        if (Selector._attrFilters[match[1]]) { // convert class to className, etc.
                            match[1] = Selector._attrFilters[match[1]];
                        }

                        test = parser.fn(match, token);
                        if (test === false) { // selector not supported
                            found = false;
                            break outer;
                        } else if (test) {
                            token.tests.push(test);
                        }

                        if (!selector.length || parser.name === COMBINATOR) {
                            tokens.push(token);
                            token = Selector._getToken(token);
                            if (parser.name === COMBINATOR) {
                                token.combinator = Y.Selector.combinators[match[1]];
                            }
                        }
                        found = true;
                    }
                }
            } while (found && selector.length);

            if (!found || selector.length) { // not fully parsed
                tokens = [];
            }
            return tokens;
        }
600866
function closest (el, selector, scope) {
  scope = scope || document.documentElement

  // walk up the dom
  while (el && el !== scope) {
    if (matches(el, selector)) return el
    el = el.parentNode
  }

  // check scope for match
  return matches(el, selector) ? el : null
}
945931
public void check(String locator) {
        getDispatcher().beforeCheck(this, locator);
        
        this.check();
        validatePresenceOfAlert();
        WebDriverWaitUtils.waitUntilElementIsPresent(locator);
        
        getDispatcher().afterUncheck(this, locator);
    }
943443
private void searchAndLaunch(String mode, Object... scope) {
		final ElementDescription element = searchAndSelect(true, scope);
		if (element != null) {
			try {
				launch(element.projectName, element.elementName, mode);
			} catch (CoreException e) {
				SARLEclipsePlugin.getDefault().openError(getShell(),
						io.sarl.eclipse.util.Messages.AbstractSarlScriptInteractiveSelector_1,
						e.getStatus().getMessage(), e);
			}
		}
	}
933311
def run(self, lines):
        
        text = "\n".join(lines)
        while 1:
            m = FENCED_BLOCK_RE.search(text)
            if not m:
                break
            lang = m.group('lang')
            linenums = bool(m.group('linenums'))
            html = highlight_syntax(m.group('code'), lang, linenums=linenums)
            placeholder = self.markdown.htmlStash.store(html, safe=True)
            text = '{}\n{}\n{}'.format(
                text[:m.start()],
                placeholder,
                text[m.end():]
            )

        return text.split("\n")
401751
function(attr, options) {
                    // check if we should only look within current scope
                    var stopLookup;
                    if (attr.substr(0, 2) === './') {
                        // set flag to halt lookup from walking up scope
                        stopLookup = true;
                        // stop lookup from checking parent scopes
                        attr = attr.substr(2);
                    }
                    // check if we should be running this on a parent.
                    else if (attr.substr(0, 3) === "../") {
                        return this._parent.read(attr.substr(3), options);
                    } else if (attr === "..") {
                        return {
                            value: this._parent._context
                        };
                    } else if (attr === "." || attr === "this") {
                        return {
                            value: this._context
                        };
                    }

                    // Array of names from splitting attr string into names.  ```"a.b\.c.d\\.e" //-> ['a', 'b', 'c', 'd.e']```
                    var names = attr.indexOf('\\.') === -1 ?
                    // Reference doesn't contain escaped periods
                    attr.split('.')
                    // Reference contains escaped periods ```(`a.b\.c.foo` == `a["b.c"].foo)```
                    : getNames(attr),
                        // The current context (a scope is just data and a parent scope).
                        context,
                        // The current scope.
                        scope = this,
                        // While we are looking for a value, we track the most likely place this value will be found.
                        // This is so if there is no me.name.first, we setup a listener on me.name.
                        // The most likely candidate is the one with the most "read matches" "lowest" in the
                        // context chain.
                        // By "read matches", we mean the most number of values along the key.
                        // By "lowest" in the context chain, we mean the closest to the current context.
                        // We track the starting position of the likely place with `defaultObserve`.
                        defaultObserve,
                        // Tracks how to read from the defaultObserve.
                        defaultReads = [],
                        // Tracks the highest found number of "read matches".
                        defaultPropertyDepth = -1,
                        // `scope.read` is designed to be called within a compute, but
                        // for performance reasons only listens to observables within one context.
                        // This is to say, if you have me.name in the current context, but me.name.first and
                        // we are looking for me.name.first, we don't setup bindings on me.name and me.name.first.
                        // To make this happen, we clear readings if they do not find a value.  But,
                        // if that path turns out to be the default read, we need to restore them.  This
                        // variable remembers those reads so they can be restored.
                        defaultComputeReadings,
                        // Tracks the default's scope.
                        defaultScope,
                        // Tracks the first found observe.
                        currentObserve,
                        // Tracks the reads to get the value for a scope.
                        currentReads;

                    // Goes through each scope context provided until it finds the key (attr).  Once the key is found
                    // then it's value is returned along with an observe, the current scope and reads.
                    // While going through each scope context searching for the key, each observable found is returned and
                    // saved so that either the observable the key is found in can be returned, or in the case the key is not
                    // found in an observable the closest observable can be returned.

                    while (scope) {
                        context = scope._context;
                        if (context !== null) {
                            var data = can.compute.read(context, names, can.simpleExtend({

                                        foundObservable: function(observe, nameIndex) {
                                            currentObserve = observe;
                                            currentReads = names.slice(nameIndex);
                                        },
                                        // Called when we were unable to find a value.
                                        earlyExit: function(parentValue, nameIndex) {

                                            if (nameIndex > defaultPropertyDepth) {
                                                defaultObserve = currentObserve;
                                                defaultReads = currentReads;
                                                defaultPropertyDepth = nameIndex;
                                                defaultScope = scope;

                                                defaultComputeReadings = can.__clearReading();
                                            }
                                        },
                                        // Execute anonymous functions found along the way
                                        executeAnonymousFunctions: true
                                    }, options));
                            // **Key was found**, return value and location data
                            if (data.value !== undefined) {
                                return {
                                    scope: scope,
                                    rootObserve: currentObserve,
                                    value: data.value,
                                    reads: currentReads
                                };
                            }
                        }
                        // Prevent prior readings and then move up to the next scope.
                        can.__clearReading();
                        if (!stopLookup) {
                            // Move up to the next scope.
                            scope = scope._parent;
                        } else {
                            scope = null;
                        }
                    }

                    // **Key was not found**, return undefined for the value.  Unless an observable was
                    // found in the process of searching for the key, then return the most likely observable along with it's
                    // scope and reads.

                    if (defaultObserve) {
                        can.__setReading(defaultComputeReadings);
                        return {
                            scope: defaultScope,
                            rootObserve: defaultObserve,
                            reads: defaultReads,
                            value: undefined
                        };
                    } else {
                        return {
                            names: names,
                            value: undefined
                        };
                    }
                }
168450
function(selector) {
  const method = this.matches || this.matchesSelector ||
    this.mozMatchesSelector || this.msMatchesSelector ||
    this.oMatchesSelector || this.webkitMatchesSelector;
  return method && method.call(this, selector);
}
1360196
function _findMatchingRulesInStyleBlocks(htmlDocument, selector, resultSelectors) {
        // HTMLUtils requires a real CodeMirror instance; make sure we can give it the right Editor
        var htmlEditor = EditorManager.getCurrentFullEditor();
        if (htmlEditor.document !== htmlDocument) {
            console.error("Cannot search for <style> blocks in HTML file other than current editor");
            return;
        }

        // Find all <style> blocks in the HTML file
        var styleBlocks = HTMLUtils.findStyleBlocks(htmlEditor);

        styleBlocks.forEach(function (styleBlockInfo) {
            // Search this one <style> block's content, appending results to 'resultSelectors'
            var oneStyleBlockMatches = _findAllMatchingSelectorsInText(styleBlockInfo.text, selector);
            _addSelectorsToResults(resultSelectors, oneStyleBlockMatches, htmlDocument, styleBlockInfo.start.line);
        });
    }
31298
def pre_process_code_block(block):
        
        if 'indent' in block and block['indent']:
            indent = r'^' + block['indent']
            block['content'] = re.sub(indent, '', block['icontent'],
                                      flags=re.MULTILINE)
208350
function check(node) {
    				var scope = context.getScope();
    				checkScope(scope);
    				// If using ES6 modules check the child 'module' scope
    				if (node.type === "Program" && node.sourceType === "module"){
    					checkScope(scope.childScopes[0]);
    				}
        		}
537336
def visit_literal_block(self, node):
        """"""
        # For "..code-block:: language"
        language = node.get('language', None)
        is_code_node = False
        if not language:
            # For "..code:: language"
            is_code_node = True
            classes = node.get('classes')
            if 'code' in classes:
                language = classes[-1]
            else:
                return

        if language in self.ignore['languages']:
            return

        if language == 'doctest' or (
                language == 'python' and
                node.rawsource.lstrip().startswith('>>> ')):
            self.visit_doctest_block(node)
            raise docutils.nodes.SkipNode

        checker = {
            'bash': bash_checker,
            'c': c_checker,
            'cpp': cpp_checker,
            'json': lambda source, _: lambda: check_json(source),
            'xml': lambda source, _: lambda: check_xml(source),
            'python': lambda source, _: lambda: check_python(source),
            'rst': lambda source, _: lambda: check_rst(source,
                                                       ignore=self.ignore)
        }.get(language)

        if checker:
            run = checker(node.rawsource, self.working_directory)
            self._add_check(node=node,
                            run=run,
                            language=language,
                            is_code_node=is_code_node)

        raise docutils.nodes.SkipNode
1182533
function(ptor) {

  /**
   * ElementArrayFinder is used for operations on an array of elements (as opposed
   * to a single element).
   *
   * The ElementArrayFinder is used to set up a chain of conditions that identify
   * an array of elements. In particular, you can call all(locator) and
   * filter(filterFn) to return a new ElementArrayFinder modified by the
   * conditions, and you can call get(index) to return a single ElementFinder at
   * position 'index'.
   *
   * Similar to jquery, ElementArrayFinder will search all branches of the DOM
   * to find the elements that satify the conditions (i.e. all, filter, get).
   * However, an ElementArrayFinder will not actually retrieve the elements until
   * an action is called, which means it can be set up in helper files (i.e.
   * page objects) before the page is available, and reused as the page changes.
   *
   * You can treat an ElementArrayFinder as an array of WebElements for most
   * purposes, in particular, you may perform actions (i.e. click, getText) on
   * them as you would an array of WebElements. The action will apply to
   * every element identified by the ElementArrayFinder. ElementArrayFinder
   * extends Promise, and once an action is performed on an ElementArrayFinder,
   * the latest result can be accessed using then, and will be returned as an
   * array of the results; the array has length equal to the length of the
   * elements found by the ElementArrayFinder and each result represents the
   * result of performing the action on the element. Unlike a WebElement, an
   * ElementArrayFinder will wait for the angular app to settle before
   * performing finds or actions.
   *
   * @alias element.all(locator)
   * @view
   * <ul class="items">
   *   <li>First</li>
   *   <li>Second</li>
   *   <li>Third</li>
   * </ul>
   *
   * @example
   * element.all(by.css('.items li')).then(function(items) {
   *   expect(items.length).toBe(3);
   *   expect(items[0].getText()).toBe('First');
   * });
   *
   * @constructor
   * @param {function(): Array.<webdriver.WebElement>} getWebElements A function
   *    that returns a list of the underlying Web Elements.
   * @param {webdriver.Locator} locator The most relevant locator. It is only
   *    used for error reporting and ElementArrayFinder.locator.
   * @param {Array.<webdriver.promise.Promise>} opt_actionResults An array
   *    of promises which will be retrieved with then. Resolves to the latest
   *    action result, or null if no action has been called.
   * @return {ElementArrayFinder}
   */
  var ElementArrayFinder = function(getWebElements, locator, opt_actionResults) {
    this.getWebElements = getWebElements || null;
    this.actionResults_ = opt_actionResults;
    this.locator_ = locator;

    var self = this;
    WEB_ELEMENT_FUNCTIONS.forEach(function(fnName) {
      self[fnName] = function() {
        var callerError = new Error();
        var args = arguments;
        var actionFn = function(webElem) {
          return webElem[fnName].apply(webElem, args).then(null, function(e) {
            e.stack = e.stack + '\n' + callerError.stack;
            throw e;
          });
        };
        return self.applyAction_(actionFn);
      };
    });
  };
  util.inherits(ElementArrayFinder, webdriver.promise.Promise);

  /**
   * Calls to ElementArrayFinder may be chained to find an array of elements
   * using the current elements in this ElementArrayFinder as the starting point.
   * This function returns a new ElementArrayFinder which would contain the
   * children elements found (and could also be empty).
   *
   * @alias element.all(locator).all(locator)
   * @view
   * <div id='id1' class="parent">
   *   <ul>
   *     <li class="foo">1a</li>
   *     <li class="baz">1b</li>
   *   </ul>
   * </div>
   * <div id='id2' class="parent">
   *   <ul>
   *     <li class="foo">2a</li>
   *     <li class="bar">2b</li>
   *   </ul>
   * </div>
   *
   * @example
   * var foo = element.all(by.css('.parent')).all(by.css('.foo'))
   * expect(foo.getText()).toEqual(['1a', '2a'])
   * var baz = element.all(by.css('.parent')).all(by.css('.baz'))
   * expect(baz.getText()).toEqual(['1b'])
   * var nonexistent = element.all(by.css('.parent')).all(by.css('.NONEXISTENT'))
   * expect(nonexistent.getText()).toEqual([''])
   *
   * @param {webdriver.Locator} subLocator
   * @return {ElementArrayFinder}
   */
  ElementArrayFinder.prototype.all = function(locator) {
    var self = this;
    var getWebElements = function() {
      if (self.getWebElements === null) {
        // This is the first time we are looking for an element
        return ptor.waitForAngular().then(function() {
          if (locator.findElementsOverride) {
            return locator.findElementsOverride(ptor.driver, null, ptor.rootEl);
          } else {
            return ptor.driver.findElements(locator);
          }
        });
      } else {
        return self.getWebElements().then(function(parentWebElements) {
          var childrenPromiseList = [];
          // For each parent web element, find their children and construct a 
          // list of Promise<List<child_web_element>>
          parentWebElements.forEach(function(parentWebElement) {
            var childrenPromise = locator.findElementsOverride ?
                locator.findElementsOverride(ptor.driver, parentWebElement, ptor.rootEl) :
                parentWebElement.findElements(locator);
            childrenPromiseList.push(childrenPromise);
          });


          // Resolve the list of Promise<List<child_web_elements>> and merge into
          // a single list
          return webdriver.promise.all(childrenPromiseList).then(
              function(resolved) {
                var childrenList = [];
                resolved.forEach(function(resolvedE) {
                  childrenList = childrenList.concat(resolvedE);
                });
                return childrenList;
              });
        });
      }
    };
    return new ElementArrayFinder(getWebElements, locator);
  };

  /**
   * Apply a filter function to each element within the ElementArrayFinder. Returns
   * a new ElementArrayFinder with all elements that pass the filter function. The
   * filter function receives the ElementFinder as the first argument
   * and the index as a second arg.
   * This does not actually retrieve the underlying list of elements, so it can
   * be used in page objects.
   *
   * @alias element.all(locator).filter(filterFn)
   * @view
   * <ul class="items">
   *   <li class="one">First</li>
   *   <li class="two">Second</li>
   *   <li class="three">Third</li>
   * </ul>
   *
   * @example
   * element.all(by.css('.items li')).filter(function(elem, index) {
   *   return elem.getText().then(function(text) {
   *     return text === 'Third';
   *   });
   * }).then(function(filteredElements) {
   *   filteredElements[0].click();
   * });
   *
   * @param {function(ElementFinder, number): webdriver.WebElement.Promise} filterFn 
   *     Filter function that will test if an element should be returned.
   *     filterFn can either return a boolean or a promise that resolves to a boolean.
   * @return {!ElementArrayFinder} A ElementArrayFinder that represents an array
   *     of element that satisfy the filter function.
   */
  ElementArrayFinder.prototype.filter = function(filterFn) {
    var self = this;
    var getWebElements = function() {
      return self.getWebElements().then(function(parentWebElements) {
        var list = [];
        parentWebElements.forEach(function(parentWebElement, index) {
          var elementFinder = self.get(index); // Wrap in ElementFinder
          var filterResults = filterFn(elementFinder, index);
          if (filterResults instanceof webdriver.promise.Promise) {
            filterResults.then(function(satisfies) {
              if (satisfies) {
                list.push(parentWebElements[index]);
              }
            });
          } else if (filterResults) {
            list.push(parentWebElements[index]);
          }
        });
        return list;
      });
    };
    return new ElementArrayFinder(getWebElements, this.locator_);
  };

  /**
   * Get an element within the ElementArrayFinder by index. The index starts at 0.
   * This does not actually retrieve the underlying element.
   *
   * @alias element.all(locator).get(index)
   * @view
   * <ul class="items">
   *   <li>First</li>
   *   <li>Second</li>
   *   <li>Third</li>
   * </ul>
   *
   * @example
   * var list = element.all(by.css('.items li'));
   * expect(list.get(0).getText()).toBe('First');
   * expect(list.get(1).getText()).toBe('Second');
   *
   * @param {number} index Element index.
   * @return {ElementFinder} finder representing element at the given index.
   */ 
  ElementArrayFinder.prototype.get = function(index) {
    var self = this;
    var getWebElements = function() {
      return self.getWebElements().then(function(parentWebElements) {
        if (index === -1) {
          // -1 is special and means last
          index = parentWebElements.length - 1;
        }
        if (index >= parentWebElements.length) {
          throw new Error('Index out of bound. Trying to access element at ' +
              'index:' + index + ', but there are only ' +
              parentWebElements.length + ' elements');
        }
        return [parentWebElements[index]];
      });
    };
    return new ElementArrayFinder(getWebElements, this.locator_).toElementFinder_();
  };

  /**
   * Get the first matching element for the ElementArrayFinder. This does not
   * actually retrieve the underlying element.
   *
   * @alias element.all(locator).first()
   * @view
   * <ul class="items">
   *   <li>First</li>
   *   <li>Second</li>
   *   <li>Third</li>
   * </ul>
   *
   * @example
   * var first = element.all(by.css('.items li')).first();
   * expect(first.getText()).toBe('First');
   *
   * @return {ElementFinder} finder representing the first matching element
   */
  ElementArrayFinder.prototype.first = function() {
    return this.get(0);
  };

  /**
   * Get the last matching element for the ElementArrayFinder. This does not
   * actually retrieve the underlying element.
   *
   * @alias element.all(locator).last()
   * @view
   * <ul class="items">
   *   <li>First</li>
   *   <li>Second</li>
   *   <li>Third</li>
   * </ul>
   *
   * @example
   * var last = element.all(by.css('.items li')).last();
   * expect(last.getText()).toBe('Third');
   *
   * @return {ElementFinder} finder representing the last matching element
   */
  ElementArrayFinder.prototype.last = function() {
    return this.get(-1);
  };

  /**
   * Shorthand function for finding arrays of elements by css.
   *
   * @type {function(string): ElementArrayFinder}
   */
  ElementArrayFinder.prototype.$$ = function(selector) {
    return this.all(webdriver.By.css(selector));
  };

  /**
   * Returns an ElementFinder representation of ElementArrayFinder. It ensures
   * that the ElementArrayFinder resolves to one and only one underlying element.
   *
   * @return {ElementFinder} An ElementFinder representation
   * @private
   */
  ElementArrayFinder.prototype.toElementFinder_ = function() {
    return new ElementFinder(this);
  };

  /**
   * Count the number of elements represented by the ElementArrayFinder.
   *
   * @alias element.all(locator).count()
   * @view
   * <ul class="items">
   *   <li>First</li>
   *   <li>Second</li>
   *   <li>Third</li>
   * </ul>
   *
   * @example
   * var list = element.all(by.css('.items li'));
   * expect(list.count()).toBe(3);
   *
   * @return {!webdriver.promise.Promise} A promise which resolves to the
   *     number of elements matching the locator.
   */
  ElementArrayFinder.prototype.count = function() {
    return this.getWebElements().then(function(arr) {
      return arr.length;
    }, function(err) {
      if (err.code == webdriver.error.ErrorCode.NO_SUCH_ELEMENT) {
        return 0;
      } else {
        throw err;
      }
    });
  };

  /**
   * Returns the most relevant locator.
   * i.e.
   *     $('#ID1').locator() returns by.css('#ID1')
   *     $('#ID1').$('#ID2').locator() returns by.css('#ID2')
   *     $$('#ID1').filter(filterFn).get(0).click().locator() returns by.css('#ID1')
   * @return {webdriver.Locator}
   */
  ElementArrayFinder.prototype.locator = function() {
    return this.locator_;
  };

  /**
   * Apply an action function to every element in the ElementArrayFinder,
   * and return a new ElementArrayFinder that contains the results of the actions.
   *
   * @param {function(ElementFinder)} actionFn
   *
   * @return {ElementArrayFinder}
   * @private
   */
  ElementArrayFinder.prototype.applyAction_ = function(actionFn) {
    var actionResults = this.getWebElements().then(function(arr) {
      var list = [];
      arr.forEach(function(webElem) {
        list.push(actionFn(webElem));
      });
      return webdriver.promise.all(list);
    });
    return new ElementArrayFinder(this.getWebElements, this.locator_, actionResults);
  };

  /**
   * Represents the ElementArrayFinder as an array of ElementFinders.
   *
   * @return {Array.<ElementFinder>} Return a promise, which resolves to a list 
   *     of ElementFinders specified by the locator.
   */
  ElementArrayFinder.prototype.asElementFinders_ = function() {
    var self = this; 
    return this.getWebElements().then(function(arr) {
      var list = [];
      arr.forEach(function(webElem, index) {
        list.push(self.get(index));
      });
      return list; 
    });
  };

  /**
   * Retrieve the elements represented by the ElementArrayFinder. The input
   * function is passed to the resulting promise, which resolves to an
   * array of ElementFinders.
   *
   * @alias element.all(locator).then(thenFunction)
   * @view
   * <ul class="items">
   *   <li>First</li>
   *   <li>Second</li>
   *   <li>Third</li>
   * </ul>
   *
   * @example
   * element.all(by.css('.items li')).then(function(arr) {
   *   expect(arr.length).toEqual(3);
   * });
   *
   * @param {function(Array.<ElementFinder>)} fn
   * @param {function(Error)} errorFn
   *
   * @type {webdriver.promise.Promise} a promise which will resolve to
   *     an array of ElementFinders represented by the ElementArrayFinder.
   */
  ElementArrayFinder.prototype.then = function(fn, errorFn) {
    if (this.actionResults_) {
      return this.actionResults_.then(fn, errorFn);
    } else {
      return this.asElementFinders_().then(fn, errorFn);
    }
  };

  /**
   * Calls the input function on each ElementFinder represented by the ElementArrayFinder.
   *
   * @alias element.all(locator).each(eachFunction)
   * @view
   * <ul class="items">
   *   <li>First</li>
   *   <li>Second</li>
   *   <li>Third</li>
   * </ul>
   *
   * @example
   * element.all(by.css('.items li')).each(function(element) {
   *   // Will print First, Second, Third.
   *   element.getText().then(console.log);
   * });
   *
   * @param {function(ElementFinder)} fn Input function
   */
  ElementArrayFinder.prototype.each = function(fn) {
    return this.asElementFinders_().then(function(arr) {
      arr.forEach(function(elementFinder, index) {
        fn(elementFinder, index);
      });
    });
  };

  /**
   * Apply a map function to each element within the ElementArrayFinder. The
   * callback receives the ElementFinder as the first argument and the index as
   * a second arg.
   *
   * @alias element.all(locator).map(mapFunction)
   * @view
   * <ul class="items">
   *   <li class="one">First</li>
   *   <li class="two">Second</li>
   *   <li class="three">Third</li>
   * </ul>
   *
   * @example
   * var items = element.all(by.css('.items li')).map(function(elm, index) {
   *   return {
   *     index: index,
   *     text: elm.getText(),
   *     class: elm.getAttribute('class')
   *   };
   * });
   * expect(items).toEqual([
   *   {index: 0, text: 'First', class: 'one'},
   *   {index: 1, text: 'Second', class: 'two'},
   *   {index: 2, text: 'Third', class: 'three'}
   * ]);
   *
   * @param {function(ElementFinder, number)} mapFn Map function that
   *     will be applied to each element.
   * @return {!webdriver.promise.Promise} A promise that resolves to an array
   *     of values returned by the map function.
   */
  ElementArrayFinder.prototype.map = function(mapFn) {
    return this.asElementFinders_().then(function(arr) {
      var list = [];
      arr.forEach(function(elementFinder, index) {
        var mapResult = mapFn(elementFinder, index);
        // All nested arrays and objects will also be fully resolved.
        webdriver.promise.fullyResolved(mapResult).then(function(resolved) {
          list.push(resolved);
        });
      });
      return list;
    });
  };

  /**
   * Apply a reduce function against an accumulator and every element found 
   * using the locator (from left-to-right). The reduce function has to reduce
   * every element into a single value (the accumulator). Returns promise of 
   * the accumulator. The reduce function receives the accumulator, current 
   * ElementFinder, the index, and the entire array of ElementFinders, 
   * respectively.
   *
   * @alias element.all(locator).reduce(reduceFn)
   * @view
   * <ul class="items">
   *   <li class="one">First</li>
   *   <li class="two">Second</li>
   *   <li class="three">Third</li>
   * </ul>
   *
   * @example
   * var value = element.all(by.css('.items li')).reduce(function(acc, elem) {
   *   return elem.getText().then(function(text) {
   *     return acc + text + ' ';
   *   });
   * });
   *
   * expect(value).toEqual('First Second Third ');
   *
   * @param {function(number, ElementFinder, number, Array.<ElementFinder>)} 
   *     reduceFn Reduce function that reduces every element into a single value.
   * @param {*} initialValue Initial value of the accumulator. 
   * @return {!webdriver.promise.Promise} A promise that resolves to the final
   *     value of the accumulator. 
   */
  ElementArrayFinder.prototype.reduce = function(reduceFn, initialValue) {
    var valuePromise = webdriver.promise.fulfilled(initialValue);
    return this.asElementFinders_().then(function(arr) {
      arr.forEach(function(elementFinder, index) {
        valuePromise = valuePromise.then(function(value) {
          return reduceFn(value, elementFinder, index, arr);
        });
      });
      return valuePromise;
    });
  };

  /**
   * Evaluates the input as if it were on the scope of the current underlying
   * elements.
   * @param {string} expression
   *
   * @return {ElementArrayFinder} which resolves to the
   *     evaluated expression for each underlying element.
   *     The result will be resolved as in
   *     {@link webdriver.WebDriver.executeScript}. In summary - primitives will
   *     be resolved as is, functions will be converted to string, and elements
   *     will be returned as a WebElement.
   */
  ElementArrayFinder.prototype.evaluate = function(expression) {
    var evaluationFn = function(webElem) {
      return webElem.getDriver().executeScript(
          clientSideScripts.evaluate, webElem, expression);
    };
    return this.applyAction_(evaluationFn);
  };

  /**
   * Determine if animation is allowed on the current underlying elements.
   * @param {string} value
   *
   * @return {ElementArrayFinder} which resolves to whether animation is allowed.
   */
  ElementArrayFinder.prototype.allowAnimations = function(value) {
    var allowAnimationsTestFn = function(webElem) {
      return webElem.getDriver().executeScript(
          clientSideScripts.allowAnimations, webElem, value);
    };
    return this.applyAction_(allowAnimationsTestFn);
  };

  /**
   * The ElementFinder simply represents a single element of an
   * ElementArrayFinder (and is more like a convenience object). As a result,
   * anything that can be done with an ElementFinder, can also be done using
   * an ElementArrayFinder.
   *
   * The ElementFinder can be treated as a WebElement for most purposes, in 
   * particular, you may perform actions (i.e. click, getText) on them as you
   * would a WebElement. ElementFinders extend Promise, and once an action 
   * is performed on an ElementFinder, the latest result from the chain can be 
   * accessed using then. Unlike a WebElement, an ElementFinder will wait for
   * angular to settle before performing finds or actions.
   *
   * ElementFinder can be used to build a chain of locators that is used to find
   * an element. An ElementFinder does not actually attempt to find the element 
   * until an action is called, which means they can be set up in helper files 
   * before the page is available. 
   *
   * @alias element(locator)
   * @view
   * <span>{{person.name}}</span>
   * <span ng-bind="person.email"></span>
   * <input type="text" ng-model="person.name"/>
   *
   * @example
   * // Find element with {{scopeVar}} syntax.
   * element(by.binding('person.name')).getText().then(function(name) {
   *   expect(name).toBe('Foo');
   * });
   *
   * // Find element with ng-bind="scopeVar" syntax.
   * expect(element(by.binding('person.email')).getText()).toBe('foo@bar.com');
   *
   * // Find by model.
   * var input = element(by.model('person.name'));
   * input.sendKeys('123');
   * expect(input.getAttribute('value')).toBe('Foo123');
   *
   * @constructor
   * @param {ElementArrayFinder} elementArrayFinder The ElementArrayFinder
   *     that this is branched from.
   * @return {ElementFinder}
   */
  var ElementFinder = function(elementArrayFinder) {
    if (!elementArrayFinder) {
      throw new Error('BUG: elementArrayFinder cannot be empty');
    }
    this.parentElementArrayFinder = elementArrayFinder;

    // This filter verifies that there is only 1 element returned by the 
    // elementArrayFinder. It will warn if there are more than 1 element and
    // throw an error if there are no elements.
    var getWebElements = function() {
      return elementArrayFinder.getWebElements().then(function(webElements) {
        if (webElements.length === 0) {
          throw new webdriver.error.Error(
              webdriver.error.ErrorCode.NO_SUCH_ELEMENT,
              'No element found using locator: ' +
                  elementArrayFinder.locator_.toString());
        } else {
          if (webElements.length > 1) {
            console.log('warning: more than one element found for locator ' +
                elementArrayFinder.locator_.toString() +
                ' - you may need to be more specific');
          }
          return [webElements[0]];
        }
      });
    };

    // Store a copy of the underlying elementArrayFinder, but with the more
    // restrictive getWebElements (which checks that there is only 1 element).
    this.elementArrayFinder_ = new ElementArrayFinder(
        getWebElements, elementArrayFinder.locator_,
        elementArrayFinder.actionResults_);

    // Decorate ElementFinder with webdriver functions. Simply calls the
    // underlying elementArrayFinder to perform these functions.
    var self = this;
    WEB_ELEMENT_FUNCTIONS.forEach(function(fnName) {
      self[fnName] = function() {
        return self.elementArrayFinder_[fnName].
            apply(self.elementArrayFinder_, arguments).toElementFinder_();
      };
    });
  };
  util.inherits(ElementFinder, webdriver.promise.Promise);

  /**
   * See ElementArrayFinder.prototype.locator
   * @return {webdriver.Locator}
   */
  ElementFinder.prototype.locator = function() {
    return this.elementArrayFinder_.locator();
  };

  /**
   * Returns the WebElement represented by this ElementFinder.
   * Throws the WebDriver error if the element doesn't exist.
   *
   * @example
   * The following three expressions are equivalent.
   *  - element(by.css('.parent')).getWebElement();
   *  - browser.waitForAngular(); browser.driver.findElement(by.css('.parent'));
   *  - browser.findElement(by.css('.parent'))
   *
   * @alias element(locator).getWebElement()
   * @return {webdriver.WebElement}
   */
  ElementFinder.prototype.getWebElement = function() {
    var id = this.elementArrayFinder_.getWebElements().then(
        function(parentWebElements) {
          return parentWebElements[0];
        });
    return new webdriver.WebElementPromise(ptor.driver, id);
  };

  /**
   * Access the underlying actionResult of ElementFinder. Implementation allows
   * ElementFinder to be used as a webdriver.promise.Promise
   * @param {function(webdriver.promise.Promise)} fn Function which takes
   *     the value of the underlying actionResult.
   *
   * @return {webdriver.promise.Promise} Promise which contains the results of 
   *     evaluating fn.
   */
  ElementFinder.prototype.then = function(fn, errorFn) {
    return this.elementArrayFinder_.then(function(actionResults) {
      return fn(actionResults[0]);
    }, errorFn);
  };

  /** 
   * Calls to element may be chained to find an array of elements within a parent.
   *
   * @alias element(locator).all(locator)
   * @view
   * <div class="parent">
   *   <ul>
   *     <li class="one">First</li>
   *     <li class="two">Second</li>
   *     <li class="three">Third</li>
   *   </ul>
   * </div>
   *
   * @example
   * var items = element(by.css('.parent')).all(by.tagName('li'))
   *
   * @param {webdriver.Locator} subLocator
   * @return {ElementArrayFinder}
   */
  ElementFinder.prototype.all = function(subLocator) {
    return this.elementArrayFinder_.all(subLocator);
  };

  /**
   * Calls to element may be chained to find elements within a parent.
   *
   * @alias element(locator).element(locator)
   * @view
   * <div class="parent">
   *   <div class="child">
   *     Child text
   *     <div>{{person.phone}}</div>
   *   </div>
   * </div>
   *
   * @example
   * // Chain 2 element calls.
   * var child = element(by.css('.parent')).
   *     element(by.css('.child'));
   * expect(child.getText()).toBe('Child text\n555-123-4567');
   *
   * // Chain 3 element calls.
   * var triple = element(by.css('.parent')).
   *     element(by.css('.child')).
   *     element(by.binding('person.phone'));
   * expect(triple.getText()).toBe('555-123-4567');
   *
   * @param {webdriver.Locator} subLocator
   * @return {ElementFinder}
   */
  ElementFinder.prototype.element = function(subLocator) {
    return this.all(subLocator).toElementFinder_();
  };

  /**
   * Shortcut for querying the document directly with css.
   *
   * @alias $$(cssSelector)
   * @view
   * <div class="count">
   *   <span class="one">First</span>
   *   <span class="two">Second</span>
   * </div>
   *
   * @example
   * // The following protractor expressions are equivalent.
   * var list = element.all(by.css('.count span'));
   * expect(list.count()).toBe(2);
   *
   * list = $$('.count span');
   * expect(list.count()).toBe(2);
   * expect(list.get(0).getText()).toBe('First');
   * expect(list.get(1).getText()).toBe('Second');
   *
   * @param {string} selector a css selector
   * @return {ElementArrayFinder} which identifies the
   *     array of the located {@link webdriver.WebElement}s.
   */
  ElementFinder.prototype.$$ = function(selector) {
    return this.all(webdriver.By.css(selector));
  };

  /**
   * Shortcut for querying the document directly with css.
   *
   * @alias $(cssSelector)
   * @view
   * <div class="count">
   *   <span class="one">First</span>
   *   <span class="two">Second</span>
   * </div>
   *
   * @example
   * var item = $('.count .two');
   * expect(item.getText()).toBe('Second');
   *
   * @param {string} selector A css selector
   * @return {ElementFinder} which identifies the located
   *     {@link webdriver.WebElement}
   */
  ElementFinder.prototype.$ = function(selector) {
    return this.element(webdriver.By.css(selector));
  };

  /**
   * Determine whether the element is present on the page.
   *
   * @view
   * <span>{{person.name}}</span>
   *
   * @example
   * // Element exists.
   * expect(element(by.binding('person.name')).isPresent()).toBe(true);
   *
   * // Element not present.
   * expect(element(by.binding('notPresent')).isPresent()).toBe(false);
   *
   * @return {ElementFinder} which resolves to whether
   *     the element is present on the page.
   */
  ElementFinder.prototype.isPresent = function() {
    return this.parentElementArrayFinder.count().then(function(count) {
      return !!count;
    });
  };

  /**
   * Override for WebElement.prototype.isElementPresent so that protractor waits
   * for Angular to settle before making the check.
   * 
   * @see ElementFinder.isPresent
   *
   * @param {webdriver.Locator} subLocator Locator for element to look for.
   * @return {ElementFinder} which resolves to whether
   *     the element is present on the page.
   */
  ElementFinder.prototype.isElementPresent = function(subLocator) {
    return this.element(subLocator).isPresent();
  };

  /**
   * Evaluates the input as if it were on the scope of the current element.
   * @param {string} expression
   *
   * @return {ElementFinder} which resolves to the evaluated expression.
   */
  ElementFinder.prototype.evaluate = function(expression) {
    return this.elementArrayFinder_.evaluate(expression).toElementFinder_();
  };

  /**
   * See ElementArrayFinder.prototype.allowAnimations.
   * @param {string} value
   *
   * @return {ElementFinder} which resolves to whether animation is allowed.
   */
  ElementFinder.prototype.allowAnimations = function(value) {
    return this.elementArrayFinder_.allowAnimations(value).toElementFinder_();
  };

  /**
   * Webdriver relies on this function to be present on Promises, so adding
   * this dummy function as we inherited from webdriver.promise.Promise, but
   * this function is irrelevant to our usage
   *
   * @return {boolean} Always false as ElementFinder is never in pending state.
   */
  ElementFinder.prototype.isPending = function() {
    return false;
  };

  var element = function(locator) {
    return new ElementArrayFinder().all(locator).toElementFinder_();
  };

  element.all = function(locator) {
    return new ElementArrayFinder().all(locator);
  };

  return element;
}
248137
def is_present_no_wait(self, locator):
        

        # first attempt to locate the element

        def execute():
            '''
            Generic function to execute wait
            '''
            return True if len(self.locator_handler.find_by_locator(self.driver, locator, True)) < 0 else False

        return self.execute_and_handle_webdriver_exceptions(
            execute, timeout=0, locator=locator, failure_message='Error running webdriver.find_all.')
432242
def execute_helper(block, opts)
      if_condition = execute_helper_condition(opts[:if])
      unless_condition = !execute_helper_condition(opts[:unless], false)

      block.call if if_condition && unless_condition
    end
497946
def href_of(scope, selector)
      if node = scope.css(selector).first
        node.attr('href')
      end
    end
978186
private static void appendLocatorXPath(StringBuilder builder, String locatorName, WebLocator locator, boolean compact) {
        String path = locator.getXPath();
        String xpathLocatorVar = "xpath_" + locatorName;
        String newLine = compact ? "" : "\n";
        builder.append("var ").append(xpathLocatorVar).append("Path = \"").append(path).append("\";").append(newLine);
        builder.append("var ").append(xpathLocatorVar).append(" = $x(").append(xpathLocatorVar).append("Path);").append(newLine);
        builder.append("if (").append(xpathLocatorVar).append("[0]) {").append(newLine);
        builder.append("  console.info('").append(locatorName).append("', ").append(xpathLocatorVar).append("[0]);").append(newLine);
        builder.append("  if (").append(xpathLocatorVar).append(".length > 1) console.warn('  found more elements', ").append(xpathLocatorVar).append(");").append(newLine);
        builder.append("} else {").append(newLine);
        builder.append("  console.error('").append(locatorName).append("', ' - not found!');").append(newLine);
        builder.append("  console.warn(\"  \"+").append(xpathLocatorVar).append("Path);").append(newLine);
        builder.append("}").append(newLine).append(newLine);
    }