Returns all available string operands.

@param boolean $includeSelector
@return array
168472
public static function getStringOperands($includeSelector = false)
    {
        $values = array(
            self::STRING_STARTS,
            self::STRING_ENDS,
            self::STRING_EQUALS,
            self::STRING_CONTAINS,
        );

        if ($includeSelector) {
            $values[] = self::OPERAND_SELECTOR;
        }

        return $values;
    }
23740
public function getFromString($includeText = true)
    {
        $statement = "";

        if (!$this->from) {
            return $statement;
        }

        $statement .= $this->getFrom();

        if ($this->getFromAlias()) {
            $statement .= " AS " . $this->getFromAlias();
        }

        // Add any JOINs.
        $statement .= " " . $this->getJoinString();

        $statement = rtrim($statement);

        if ($includeText && $statement) {
            $statement = "FROM " . $statement;
        }

        return $statement;
    }
183124
public function _includeElements(&$element)
    {
        if ($element->isGlobal() && !$element->isFinal() && !$this->_globals) {
            return FALSE;
        } elseif ($element->isGlobal() && $element->isFinal() && !$this->_constants) {
            return FALSE;
        } elseif (!$this->_private && $element->isPrivate()) {
            return FALSE;
        } elseif ($this->_private) {
            return TRUE;
        } elseif ($this->_protected && ($element->isPublic() || $element->isProtected())) {
            return TRUE;
        } elseif ($this->_public && $element->isPublic()) {
            return TRUE;
        }

        return FALSE;
    }
110366
protected function analyzeSelector()
    {
        if ($this->analyzed === false) {
            // Calculate specificity
            $selector = $this->getValue();

            // Set flags
            $isEscaped = false;
            $inSelectorPart = false;
            $wasEscaped = false;
            $inAttribute = false;

            $countIdSelectors = 0;
            $countClassSelectors = 0;
            $countAttributeSelectors = 0;
            $countPseudoClassSelectors = 0;
            $countTypeSelectors = 0;
            $countPseudoElementSelectors = 0;
            $countUniversalSelectors = 0;

            $charset = $this->getCharset();

            if (preg_match('/[^\x00-\x7f]/', $selector)) {
                $isAscii = false;
                $strLen = mb_strlen($selector, $charset);
            } else {
                $isAscii = true;
                $strLen = strlen($selector);
            }

            for ($i = 0, $j = $strLen; $i < $j; $i++) {
                if ($isAscii === true) {
                    $char = $selector[$i];
                } else {
                    $char = mb_substr($selector, $i, 1, $charset);
                }

                // Check for escape character
                if ($isEscaped === false && $char === "\\") {
                    $isEscaped = true;
                } else {
                    $wasEscaped = $isEscaped;
                    $isEscaped = false;
                }

                // Filter user-defined strings, that can contain special characters, comments etc.
                // and therefore need to be ignored.
                if ($inAttribute === false && $wasEscaped === false && $char === "[") {
                    $countAttributeSelectors++;
                    $inAttribute = true;
                    continue;
                } else {
                    if ($wasEscaped === false && $char === "]") {
                        $inAttribute = false;
                        continue;
                    }
                }

                if ($inAttribute === false) {
                    if ($char === "#") {
                        $countIdSelectors++;
                        $inSelectorPart = true;
                    } elseif ($char === ".") {
                        $countClassSelectors++;
                        $inSelectorPart = true;
                    } elseif ($char === ":") {
                        if ($isAscii === true) {
                            $nextChars = substr($selector, $i);
                        } else {
                            $nextChars = mb_substr($selector, $i, null, $charset);
                        }
                        $nextChars = preg_replace('/^(\:(?:\:)?[-a-z]+)[^-a-z]*.*/', '\\1', $nextChars);

                        // Check for pseudo element selector
                        if (substr($nextChars, $i, 2) === "::") {
                            $countPseudoElementSelectors++;

                            // Check for pseudo element
                            if ($nextChars === "::first-line") {
                                $this->pseudoElements[] = self::PSEUDO_ELEMENT_FIRST_LINE;
                            } elseif ($nextChars === "::first-letter") {
                                $this->pseudoElements[] = self::PSEUDO_ELEMENT_FIRST_LETTER;
                                // "after" >= CSS3
                            } elseif ($nextChars === "::after") {
                                $this->pseudoElements[] = self::PSEUDO_ELEMENT_AFTER;
                                // "before" >= CSS3
                            } elseif ($nextChars === "::before") {
                                $this->pseudoElements[] = self::PSEUDO_ELEMENT_BEFORE;
                                // Other pseudo elements
                            } else {
                                $this->pseudoElements[] = self::PSEUDO_ELEMENT_UNKNOWN;
                            }
                            $i += (strlen($nextChars) - 1);

                            $inSelectorPart = true;
                            // Special pseudo class selector
                        } elseif ($nextChars === ":not") {
                            // This pseudo class selector is NOT counted, only the contained
                            // elements are counted!
                            $i += (5 - 1);
                            $inSelectorPart = false;
                            // Other pseudo class selectors
                        } else {
                            $countPseudoClassSelectors++;

                            // Check for pseudo class
                            // (and old pseudo element notation < CSS 3)
                            if ($nextChars === ":link") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_LINK;
                            } elseif ($nextChars === ":visited") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_VISITED;
                            } elseif ($nextChars === ":hover") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_HOVER;
                            } elseif ($nextChars === ":active") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_ACTIVE;
                            } elseif ($nextChars === ":focus") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_FOCUS;
                            } elseif ($nextChars === ":checked") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_CHECKED;
                            } elseif ($nextChars === ":enabled") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_ENABLED;
                            } elseif ($nextChars === ":disabled") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_DISABLED;
                            } elseif ($nextChars === ":target") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_TARGET;
                            } elseif ($nextChars === ":empty") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_EMPTY;
                            } elseif ($nextChars === ":lang") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_LANG;
                            }  elseif ($nextChars === ":root") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_ROOT;
                            } elseif ($nextChars === ":nth-child") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_NTH_CHILD;
                            } elseif ($nextChars === ":nth-last-child") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_NTH_LAST_CHILD;
                            } elseif ($nextChars === ":nth-of-type") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_NTH_OF_TYPE;
                            } elseif ($nextChars === ":nth-last-of-type") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_NTH_LAST_OF_TYPE;
                            } elseif ($nextChars === ":first-child") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_FIRST_CHILD;
                            } elseif ($nextChars === ":last-child") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_LAST_CHILD;
                            } elseif ($nextChars === ":only-child") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_ONLY_CHILD;
                            } elseif ($nextChars === ":only-of-type") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_ONLY_OF_TYPE;
                            } elseif ($nextChars === ":first-of-type") {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_FIRST_OF_TYPE;
                            } elseif ($nextChars === ":after") {
                                // Old pseudo element notation < CSS 3
                                $this->pseudoElements[] = self::PSEUDO_ELEMENT_AFTER;
                            } elseif ($nextChars === ":before") {
                                // Old pseudo element notation < CSS 3
                                $this->pseudoElements[] = self::PSEUDO_ELEMENT_BEFORE;
                            } elseif ($nextChars === ":first-line") {
                                // Old pseudo element notation < CSS 3
                                $this->pseudoElements[] = self::PSEUDO_ELEMENT_FIRST_LINE;
                            } elseif ($nextChars === ":first-letter") {
                                // Old pseudo element notation < CSS 3
                                $this->pseudoElements[] = self::PSEUDO_ELEMENT_FIRST_LETTER;
                            } else {
                                $this->pseudoClasses[] = self::PSEUDO_CLASS_UNKNOWN;
                            }
                            $i += (strlen($nextChars) - 1);

                            $inSelectorPart = true;
                        }
                    } else {
                        if ($char === "*") {
                            $countUniversalSelectors++;
                            $inSelectorPart = true;
                        } else {
                            if ($char === "+" || $char === ">" || $char === "~" || /*preg_match('/\s/', $char)*/
                                $char === " " || $char === "\t" || $char === "\f"
                            ) {
                                $inSelectorPart = false;
                            } else {
                                if ($inSelectorPart === false) {
                                    $countTypeSelectors++;
                                    $inSelectorPart = true;
                                }
                            }
                        }
                    }
                }
            }

            // Set specificity
            $this->specificity += ($countIdSelectors * 100);
            $this->specificity += ($countClassSelectors * 10);
            $this->specificity += ($countAttributeSelectors * 10);
            $this->specificity += ($countPseudoClassSelectors * 10);
            $this->specificity += ($countTypeSelectors * 1);
            $this->specificity += ($countPseudoElementSelectors * 1);
            $this->specificity += ($countUniversalSelectors * 0);

            // Update flag
            $this->analyzed = true;
        }
    }
966703
public function select($sSelector, $sOptionSelector)
    {
        $oSelectorsHandler = $this->getMinkSession()->getSelectorsHandler();
        $oSelect = null;

        if (strpos($sSelector, '/') === false) {
            $page = $this->getMinkSession()->getPage();
            $sParsedSelector = $oSelectorsHandler->xpathLiteral($sSelector);
            $oSelect = $page->find('named', array('select', $sParsedSelector));
        }

        if (is_null($oSelect)) {
            $oSelect = $this->getElementLazy($sSelector);
        }

        if (strpos($sOptionSelector, 'index=') === 0) {
            $iIndex = str_replace('index=', '', $sOptionSelector);
            $sOptionSelector = $this->_getSelectOptionByIndex($oSelect, $iIndex);
        } else {
            $sOptionSelector = str_replace(array('label=', 'value='), '', $sOptionSelector);
        }

        if (is_null($oSelect)) {
            $this->fail("Select '$sSelector' was not found!");
        }

        $oOptions = $oSelect->findAll('named', array('option', $oSelectorsHandler->xpathLiteral($sOptionSelector)));

        $oOption = $this->_getExactMatch($oOptions, $sOptionSelector);

        if (is_null($oOption)) {
            $this->fail("Option '$sOptionSelector' was not found in '$sSelector' select ");
        }

        $this->getMinkSession()->getDriver()->selectOption(
            $oSelect->getXpath(), $oOption->getValue(), false
        );

        $this->fireEvent($sSelector, 'change');
    }
373392
public function getValue($sSelector)
    {
        $element = $this->getElementLazy($sSelector);
        $mValue = $this->_getValue($element->getXpath());

        try {
            $sType = $element->getAttribute('type');
        } catch (InvalidArgumentException $e) {
            sleep(1);
            $sType = $element->getAttribute('type');
        }
        if ($sType == 'checkbox') {
            $mValue = $mValue ? 'on' : 'off';
        }

        return trim($mValue);
    }
939930
public function getUpdateString($includeText = true)
    {
        $statement = "";

        if (!$this->update) {
            return $statement;
        }

        if ($this->isInto) {
            $statement .= $this->getOptionsString(true) . 'INTO ';
        } else {
            $statement .= $this->getOptionsString(true);
        }
        $statement .= $this->getUpdate();

        // Add any JOINs.
        $statement .= " " . $this->getJoinString();

        $statement = rtrim($statement);

        if ($includeText && $statement) {
            $statement = "UPDATE " . $statement;
        }

        return $statement;
    }
935844
protected function _getElementByLink($sSelector)
    {
        $sSelector = str_replace('link=', '', $sSelector);

        $sParsedSelector = $this->getMinkSession()->getSelectorsHandler()->xpathLiteral($sSelector);
        $oElements = $this->getMinkSession()->getPage()->findAll('named', array('link', $sParsedSelector));

        if (empty($oElements)) {
            $aSelectorParts = explode(' ', $sSelector);
            $aSelectorParts = array_map(array($this->getMinkSession()->getSelectorsHandler(), 'xpathLiteral'),
                $aSelectorParts);
            $sFormedSelector = "//a[contains(.," . implode(") and contains(.,", $aSelectorParts) . ")]";
            $oElements = $this->getMinkSession()->getPage()->findAll('xpath', $sFormedSelector);
        }

        return $this->_getExactMatch($oElements, $sSelector);
    }
832703
protected function _getElementByIdOrNameXpath($sSelector)
    {
        $sSelector = $this->getMinkSession()->getSelectorsHandler()->xpathLiteral($sSelector);
        return $this->getMinkSession()->getPage()->find('xpath', "//*[@id=$sSelector or @name=$sSelector]");
    }
866416
public String getSelectorString() {
        StringBuilder sb = new StringBuilder();
        for (List<String> selector : selectors) {
            if (sb.length() > 0) {
                sb.append(",");
            }
            for (String s : selector) {
                if (sb.length() > 0) {
                    sb.append(" ");
                }
                sb.append(s);
            }
        }
        return sb.toString();
    }
1131935
public function getXpathCount($sSelector)
    {
        $page = $this->getMinkSession()->getPage();

        return count($page->findAll('xpath', $sSelector));
    }
1099073
public static function getSegments($selector)
    {
        $selector = trim($selector);

        if ($selector === '') {
            throw new InvalidSelectorException('The selector must not be empty');
        }

        $tag = '(?P<tag>[\*|\w|\-]+)?';
        $id = '(?:#(?P<id>[\w|\-]+))?';
        $classes = '(?P<classes>\.[\w|\-|\.]+)*';
        $attrs = '(?P<attrs>(?:\[.+?\])*)?';
        $name = '(?P<pseudo>[\w\-]+)';
        $expr = '(?:\((?P<expr>[^\)]+)\))';
        $pseudo = '(?::'.$name.$expr.'?)?';
        $rel = '\s*(?P<rel>>)?';

        $regexp = '/'.$tag.$id.$classes.$attrs.$pseudo.$rel.'/is';

        if (preg_match($regexp, $selector, $segments)) {
            if ($segments[0] === '') {
                throw new InvalidSelectorException(sprintf('Invalid selector "%s"', $selector));
            }

            $result['selector'] = $segments[0];

            if (isset($segments['tag']) && $segments['tag'] !== '') {
                $result['tag'] = $segments['tag'];
            }

            // if the id attribute specified
            if (isset($segments['id']) && $segments['id'] !== '') {
                $result['id'] = $segments['id'];
            }

            // if the attributes specified
            if (isset($segments['attrs'])) {
                $attributes = trim($segments['attrs'], '[]');
                $attributes = explode('][', $attributes);

                foreach ($attributes as $attribute) {
                    if ($attribute !== '') {
                        list($name, $value) = array_pad(explode('=', $attribute, 2), 2, null);

                        if ($name === '') {
                            throw new InvalidSelectorException(sprintf('Invalid selector "%s": attribute name must not be empty', $selector));
                        }

                        // equal null if specified only the attribute name
                        $result['attributes'][$name] = is_string($value) ? trim($value, '\'"') : null;
                    }
                }
            }

            // if the class attribute specified
            if (isset($segments['classes'])) {
                $classes = trim($segments['classes'], '.');
                $classes = explode('.', $classes);

                foreach ($classes as $class) {
                    if ($class !== '') {
                        $result['classes'][] = $class;
                    }
                }
            }

            // if the pseudo class specified
            if (isset($segments['pseudo']) && $segments['pseudo'] !== '') {
                $result['pseudo'] = $segments['pseudo'];

                if (isset($segments['expr']) && $segments['expr'] !== '') {
                    $result['expr'] = $segments['expr'];
                }
            }

            // if it is a direct descendant
            if (isset($segments['rel'])) {
                $result['rel'] = $segments['rel'];
            }

            return $result;
        }

        throw new InvalidSelectorException(sprintf('Invalid selector "%s"', $selector));
    }
1001785
public function all(bool $includeDeprecated = false): array {
        $result = [];
        foreach ($this->iterate($includeDeprecated) as $key => $value) {
            $result[$key] = $value;
        }
        return $result;
    }
204307
public function findAllFromString($aspectsOrElements)
    {
        $results = array();
        foreach (explode(',', $aspectsOrElements) as $aspectOrElement) {
            $aspectOrElement = trim($aspectOrElement);
            if (substr($aspectOrElement, 0, 1) == '@') {
                $els = $this->findAllWithAspect($aspectOrElement);
                foreach ($els as $el) {
                    $results[$el->ElementID] = $el;
                }
            } else {
                $el = $this->getBySlug($aspectOrElement);
                $results[$el->ElementID] = $el;
            }
        }

        return $results;
    }
1140351
private static function getSelectOptions($list, $selectedValue) {
        $result = '';

        if ($selectedValue !== null && !is_array($selectedValue)) {
            $selectedValue = array($selectedValue);
        }

        foreach ($list as $item) {
            $itemAttr = array();
            $text = '';

            if ($item instanceof SelectListItem) {
                $text = $item->text;
                $itemAttr['value'] = $item->value;

                if ($item->disabled === true) {
                    $itemAttr['disabled'] = 'disabled';
                }

                if ($selectedValue === null && $item->selected === true) {
                    $itemAttr['selected'] = 'selected';
                }
                elseif ($selectedValue !== null && in_array($item->value, $selectedValue) === true) {
                    $itemAttr['selected'] = 'selected';
                }
            }
            else {
                $text = $item;

                if ($selectedValue !== null && in_array($item, $selectedValue)) {
                    $itemAttr['selected'] = 'selected';
                }
            }

            $attr = self::buildAttributes($itemAttr);

            $result .= '<option' . (!empty($attr) ? ' ' : '') . $attr . '>';
            $result .= htmlspecialchars($text);
            $result .= '</option>';
        }

        return $result;
    }
758901
public function getText($sSelector)
    {
        $oElement = $this->getElementLazy($sSelector);
        try {
            $sText = $oElement->getText();
        } catch (Exception $e) {
            sleep(1);
            $sText = $oElement->getText();
        }
        return $sText;
    }
1169043
function parseSelector() {
    while (!source.isAtEnd()) {
      var token = source.first();

      switch (token) {
        case '.':
          return cssSelector();
        case '#':
          return cssSelector();
        case '{':
          source.shift();
          if (useHash) {
            return hashSelectorContent();
          } else {
            return parseSelectorContent();
          }

        case '/':
          cssComment();
          break;
        case "'":
          singleQuoteString();
          break;
        case '"':
          doubleQuoteString();
          break;
        default:
          source.shift();
      }
    }
  }