@param $locator
@param string $selector

@return \Behat\Mink\Element\NodeElement|mixed|null
498644
public function getElement($locator, $selector='css')
    {
        $page = $this->minkContext->getSession()->getPage();
        $element = $page->find('css', $locator);
        return $element;
    }
775742
public function filter($selector)
    {
        $converter = $this->createCssSelectorConverter();

        // The CssSelector already prefixes the selector with descendant-or-self::
        return $this->filterRelativeXPath($converter->toXPath($selector));
    }
1230557
public function withSelector(RecordSelector $selector): RecordSource
    {
        $source = clone $this;
        $source->setSelector($selector);

        return $source;
    }
1062911
public function querySelectorAll($selector)
    {
        $converter = new CssSelectorConverter();

        $xpathQuery = $converter->toXPath($selector);

        $results = $this->xpath->query($xpathQuery);

        if (!$results->item(0)) {
            return [];
        }

        $return = new NodeCollection();

        for ($i = 0; $i < $results->length; $i++) {
            $node = new Node($results->item($i));
            $return->append($node);
        }

        return $return;
    }
1231668
public function hasUncheckedField($locator)
    {
        $field = $this->findField($locator);

        return null !== $field && !$field->isChecked();
    }
1211445
public function not($selector)
    {
        $result = $this->createChildInstance();

        if ($this->length > 0) {
            if (\is_callable($selector)) {
                foreach ($this->nodes as $index => $node) {
                    if (!$selector($node, $index)) {
                        $result->addDomNode($node);
                    }
                }
            } else {
                $selection = self::create($this->document)->find($selector);

                if ($selection->length > 0) {
                    foreach ($this->nodes as $node) {
                        $matched = false;
                        foreach ($selection as $result_node) {
                            if ($result_node->isSameNode($node)) {
                                $matched = true;
                                break 1;
                            }
                        }
                        if (!$matched) {
                            $result->addDomNode($node);
                        }
                    }
                } else {
                    $result->addNodes($this->nodes);
                }
            }
        }

        return $result;
    }
949652
public function filter($selector)
    {
        $result = $this->createChildInstance();

        if ($this->length > 0) {
            if (\is_callable($selector)) {
                foreach ($this->nodes as $index => $node) {
                    if ($selector($node, $index)) {
                        $result->addDomNode($node);
                    }
                }
            } else {
                $selection = self::create($this->document)->find($selector);

                foreach ($selection as $result_node) {
                    foreach ($this->nodes as $node) {
                        if ($result_node->isSameNode($node)) {
                            $result->addDomNode($node);
                            break 1;
                        }
                    }
                }
            }
        }

        return $result;
    }
251718
public function appendSelector(FileSelector $selector)
    {
        if ($this->isReference()) {
            throw $this->noChildrenAllowed();
        }
        parent::appendSelector($selector);
    }
1318281
public function iScrollToElement($locator) {
		$el = $this->getSession()->getPage()->find('css', $locator);
		assertNotNull($el, sprintf('The element "%s" is not found', $locator));

		$id = $el->getAttribute('id');
		if(empty($id)) {
			throw new \InvalidArgumentException('Element requires an "id" attribute');
		}

		$js = sprintf("document.getElementById('%s').scrollIntoView(true);", $id);
		$this->getSession()->executeScript($js);
	}
267650
public function siblings($selector = null): NodeList {
        $results = $this->collection()->reduce(function($carry, $node) use ($selector) {
            return $carry->merge(
                $node->precedingAll($selector)->merge(
                    $node->followingAll($selector)
                )
            );
        }, $this->newNodeList());

        return $results;
    }
232436
public static function toXPath($selector)
    {
        if (isset(self::$compiled[$selector])){
            return self::$compiled[$selector];
        }

        // Select DOMText
        if ($selector === 'text') {
            return '//text()';
        }

        // Select DOMComment
        if ($selector === 'comment') {
            return '//comment()';
        }

        if (!class_exists('Symfony\\Component\\CssSelector\\CssSelectorConverter')) {
            throw new \RuntimeException('Unable to filter with a CSS selector as the Symfony CssSelector 2.8+ is not installed (you can use filterXPath instead).');
        }

        $converter = new CssSelectorConverter(true);

        $xPathQuery = $converter->toXPath($selector);
        self::$compiled[$selector] = $xPathQuery;

        return $xPathQuery;
    }
978695
public static boolean isElementPresent(String locator) {
        logger.entering(locator);
        boolean flag = false;
        try {
            flag = HtmlElementUtils.locateElement(locator) != null;
        } catch (NoSuchElementException e) { // NOSONAR
        }
        logger.exiting(flag);
        return flag;
    }
679689
public static UnindexedMatcher matcherWithSelector(Map<String, Object> selector) {
        ChildrenQueryNode root = buildExecutionTreeForSelector(selector);

        if (root == null) {
            return null;
        }

        UnindexedMatcher matcher = new UnindexedMatcher();
        matcher.root = root;

        return matcher;
    }
550147
public function findOrFail($selector)
    {
        if (! is_null($element = $this->findById($selector))) {
            return $element;
        }

        return $this->driver->findElement(
            WebDriverBy::cssSelector($this->format($selector))
        );
    }
1279015
private function buildExpressionForSelector(string $selector)
    {

        if ($expression = $this->resultCache->fetch($selector)) {
            return $expression;
        }

        try {
            $expression = $this->cssConverter->toXPath($selector);
        } catch (ExpressionErrorException $expressionErrorException) {

            // Allow for pseudo selectors
            // TODO: Find a way to validate this exception without checking strings
            if ($expressionErrorException->getMessage() !== 'Pseudo-elements are not supported.') {
                return false;
            }

            try {
                $tokens = explode(':', $selector);
                $expression = $this->cssConverter->toXPath((string)reset($tokens));
            } catch (Exception $e) {
                return false;
            }

        } catch (ExceptionInterface $e) {
            return false;
        }


        $this->resultCache->save($selector, $expression);

        return $expression;
    }
828278
public function findElement($strategy, $selector)
	{
		return $this->element($this->using($strategy)->value($selector));
	}
310872
public function find(string $selector, string $prefix = 'descendant::'): NodeList {
        $converter = new CssSelectorConverter();

        return $this->findXPath($converter->toXPath($selector, $prefix));
    }