Find a {@link By} locator by its reference name

@param elementReference
@return {@link By}
431507
public By getElementLocatorForElementReference(String elementReference) {
    	Map<String, By> objectReferenceMap = getObjectReferenceMap(By.class);
    	
        By elementLocator = objectReferenceMap.get(elementReference);
        if (elementLocator == null) {
            fail("No elementLocator is found for element name: '" + elementReference + "'. Available element references are: " + objectReferenceMap.keySet().toString());
        }
        return elementLocator;
    }
347845
public List<BeanId> getReference(final String propertyName) {
        List<BeanId> values = references.get(propertyName);
        if (values == null) {
            return null;
        }
        return values;
    }
78057
protected
  Appender findAppenderByReference(Element appenderRef) {    
    String appenderName = subst(appenderRef.getAttribute(REF_ATTR));    
    Document doc = appenderRef.getOwnerDocument();
    return findAppenderByName(doc, appenderName);
  }
528009
def getReferenceByName(self, name):
        
        if name not in self._referenceNameMap:
            raise exceptions.ReferenceNameNotFoundException(name)
        return self._referenceNameMap[name]
550723
public static ExpectedCondition<WebElement> presenceOfElementLocated(final By locator) {
    return new ExpectedCondition<WebElement>() {
      @Override
      public WebElement apply(WebDriver driver) {
        return driver.findElement(locator);
      }

      @Override
      public String toString() {
        return "presence of element located by: " + locator;
      }
    };
  }
662684
public static <T extends WebElement> Function<SearchContext, T> byToFunction(By by) {
        Function<SearchContext, T> function;
        if (by instanceof SingleElementOrNullBy) {
            // will not throw exception, but return null when no element is found
            function = sc -> (T) by.findElement(sc);
        } else {
            function = sc -> {
                // single element case will throw exception when no element is found
                List elements = by.findElements(sc);
                return (elements != null && !elements.isEmpty())? (T) elements.get(0) : null;
            };
        }
        return function;
    }
804788
@Nullable
  public static Element findFirstElement(@Nonnull final Element node, @Nonnull final String elementName) {
    Element result = null;
    for (final Element l : Utils.findDirectChildrenForName(node, elementName)) {
      result = l;
      break;
    }
    return result;
  }
320382
public static Collection<Node> findElementsByName(String elementName, Node node)
	{
		if ( node == null ||
			node.getNodeType() == Node.COMMENT_NODE ||
			node.getNodeType() == Node.TEXT_NODE )
			return null;

		HashSet<Node> results = new HashSet<Node>();

		if (elementName.equals(node.getNodeName()))
		{
			results.add(node);
		}

		NodeList nodeList = node.getChildNodes();

		if (nodeList == null)
			return null;

		int len = nodeList.getLength();

		Node child;

		for (int i = 0; i < len; i++)
		{
			child = nodeList.item(i);

			if (child.getNodeType() == Node.TEXT_NODE)
				continue;

			if (elementName.equals(child.getNodeName()))
				 results.add(child);

			// check for next
			NodeList grands = child.getChildNodes();
			if (grands != null)
			{
				int grandsCnt = grands.getLength();
				for (int x = 0; x < grandsCnt; x++)
				{
					Collection<Node> grandResults = findElementsByName(elementName, grands.item(x));

					if (grandResults != null)
						results.addAll(grandResults);
				}
			}
		}

		return results.isEmpty()? null : results;

	}
952996
def find(self, name, required):
        
        if name == None:
            raise Exception("Name cannot be null")
        
        locator = self._locate(name)
        if locator == None:
            if required:
                raise ReferenceException(None, name)
            return None
        
        return self._references.find(locator, required)
654883
public static ExpectedCondition<WebElement> presenceOfNestedElementLocatedBy(
    final WebElement element,
    final By childLocator) {

    return new ExpectedCondition<WebElement>() {

      @Override
      public WebElement apply(WebDriver webDriver) {
        return element.findElement(childLocator);
      }

      @Override
      public String toString() {
        return String.format("visibility of element located by %s", childLocator);
      }
    };
  }
1083003
@Override
	public List<WebElement> findElements(final By by) {

		return (List<WebElement>) (new StaleExceptionResolver<List<WebElement>>() {
			@Override
			public List<WebElement> execute(WebElement element) {
				List<WebElement> elements = new ArrayList<WebElement>(); // create
																			// a
																			// new
																			// list
																			// of
																			// WebElements
				for (WebElement webElement : element.findElements(by)) {
					// encapsule the WebElements inside of a WebElementAdapter
					elements.add(new WebElementAdapter(webElement, thisObject, by, false)); 
				}// end for
				return elements;
			}// end execute
		}).waitForElement();
	}
1130742
public Reference setReferenceElement(IIdType theReference) {
    if (theReference != null) {
      setReference(theReference.getValue());
    } else {
      setReference(null);
    }
    return this;
  }
84785
public static function elementSelectionStateToBe($element_or_by, $selected)
    {
        if ($element_or_by instanceof WebDriverElement) {
            return new static(
                function () use ($element_or_by, $selected) {
                    return $element_or_by->isSelected() === $selected;
                }
            );
        } else {
            if ($element_or_by instanceof WebDriverBy) {
                return new static(
                    function (WebDriver $driver) use ($element_or_by, $selected) {
                        try {
                            $element = $driver->findElement($element_or_by);

                            return $element->isSelected() === $selected;
                        } catch (StaleElementReferenceException $e) {
                            return null;
                        }
                    }
                );
            }
        }
    }
1214807
private int extractValidIndex(ElementReference ref) {
        Reference<E> iRef = asIndexedRef(ref);
        int idx = iRef.index;
        if (idx < 0 || idx >= size) {
            throw new InvalidReferenceException(
                    "Index " + idx + " is not valid for collection with size " + size + ".");
        }
        return idx;
    }
481179
public int findElement(Object bookmark, int iHandleType)
    {
        int iTargetPosition;
        Object thisBookmark = null;
        if (bookmark == null)
            return -1;
//+ Not found, look through the recordlist
        boolean bDataRecordFormat = false;
        for (iTargetPosition = 0; iTargetPosition < m_iRecordListEnd; iTargetPosition += m_iRecordListStep)
        {
            thisBookmark = this.elementAt(iTargetPosition);
            if (iTargetPosition == 0)
                if (thisBookmark instanceof DataRecord)
                    bDataRecordFormat = true;
            if (bookmark.equals(thisBookmark))
                return iTargetPosition;
            else if (bDataRecordFormat)
                if (bookmark.equals(((DataRecord)thisBookmark).getHandle(iHandleType)))
                    return iTargetPosition;
        }
//+ Still not found, do a binary search through the recordlist for a matching key
        return -1;  // Not found
    }
1151779
public ServiceReference<T> getHighestRankedReference() {
        Iterator<ConcurrentServiceReferenceElement<T>> iterator = elementSet.iterator();
        return iterator.hasNext() ? iterator.next().getReference() : null;
    }
1262888
public function findElementtypesUsingReferenceElementtype(Elementtype $referenceElementtype)
    {
        $elementtypes = array();
        foreach ($this->elementtypeManager->findAll() as $elementtype) {
            if (!$elementtype->getStructure()->getRootNode()) {
                continue;
            }
            $rii = new \RecursiveIteratorIterator($elementtype->getStructure()->getIterator(), \RecursiveIteratorIterator::SELF_FIRST);
            foreach ($rii as $node) {
                /* @var $node ElementtypeStructureNode */
                if ($node->getReferenceElementtypeId() === $referenceElementtype->getId()) {
                    $elementtypes[] = $elementtype;
                    break;
                }
            }
        }

        return $elementtypes;
    }