Get the parent of each element in the current set of matched elements, optionally filtered by a selector

@param string|self|callable|\DOMNodeList|\DOMNode|null $selector expression that filters the set of matched elements

@return self
331637
public function parent($selector=null)
    {
        $result = $this->createChildInstance();

        if (isset($this->document) && $this->length > 0) {
            foreach ($this->nodes as $node) {
                if ($node->parentNode) {
                    $result->addDomNode($node->parentNode);
                }
            }

            if ($selector) {
                $result = $result->filter($selector);
            }
        }

        return $result;
    }
741054
public function get($selector, \DOMNode $context = null, $registerNodeNS = true)
    {
        return $this->exec('query', $selector, $context, $registerNodeNS);
    }
399804
function(selector) {
        var el = this.el.querySelector(selector);
        if (el && el.parentElement !== this.el) {
            el = null;
        }
        return el;
    }
248528
public static function get($selector){
		$specificity = $selector->hasNext() ? self::get($selector->getNext()) : new self();
		
		if($selector->getIdentification()) $specificity->a++;
		if($selector->getClasses()) $specificity->b+= count($selector->getClasses());
		if($selector->getAttributes()) $specificity->b+= count($selector->getAttributes());
		if($selector->getPseudos()) $specificity->b+= count($selector->getPseudos());
		if($selector->getTagName()) $specificity->c++;
		
		return $specificity;
	}
809932
public function parent($css = null)
    {
        if ($css === '') {
            return clone  $this;
        }

        return $this->css('parent::' . ($css === null ? '*' : $css));
    }
1048874
public function querySelector($selector)
    {
        $converter = new CssSelectorConverter();

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

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

        if (!$result->item(0)) {
            return null;
        }
        return new Node($result->item(0));
    }
1293820
public function getFirstMatchingField ($selector)
    {
        $fields = $this->getFields($selector);
        if (empty($fields)) {
            return null;
        } else {
            return reset($fields);
        }
    }
872232
public function with($selector, Closure $callback)
    {
        $browser = new static(
            $this->driver, new ElementResolver($this->driver, $this->resolver->format($selector))
        );

        if ($this->page) {
            $browser->onWithoutAssert($this->page);
        }

        if ($selector instanceof Component) {
            $browser->onComponent($selector, $this->resolver);
        }

        call_user_func($callback, $browser);

        return $this;
    }
80761
public function all($selector)
    {
        try {
            return $this->driver->findElements(
                WebDriverBy::cssSelector($this->format($selector))
            );
        } catch (Exception $e) {
            //
        }

        return [];
    }
1216473
public function has($selector)
    {
        $result = $this->createChildInstance();

        if ($this->length > 0) {
            foreach ($this as $node) {
                if ($node->find($selector)->length > 0) {
                    $result->addDomNode($node->get(0));
                }
            }
        }

        return $result;
    }
1329759
protected function loadDependencies(RecordSelector $selector)
    {
        if (empty($this->dependencies)) {
            return $selector;
        }

        foreach ($this->dependencies as $dependency) {
            $selector = $selector->with(
                $dependency->getRelation(),
                $dependency->getOptions()
            );
        }

        return $selector;
    }
456014
protected static function getSelectorParts($selector)
    {
        $firstOpen = strpos($selector, '[');
        if ($firstOpen === false) {
            return array( $selector, '' );
        }
        $firstClose  = strpos($selector, ']');
        $container   = substr($selector, 0, $firstOpen);
        $subselector = substr($selector, $firstOpen + 1, $firstClose - $firstOpen - 1) . substr(
            $selector,
            $firstClose + 1
        );

        return array( $container, $subselector );
    }
424322
public function assertVisible($selector)
    {
        $fullSelector = $this->resolver->format($selector);

        PHPUnit::assertTrue(
            $this->resolver->findOrFail($selector)->isDisplayed(),
            "Element [{$fullSelector}] is not visible."
        );

        return $this;
    }
310872
public function find(string $selector, string $prefix = 'descendant::'): NodeList {
        $converter = new CssSelectorConverter();

        return $this->findXPath($converter->toXPath($selector, $prefix));
    }
952977
public function selector($selector)
    {
        if( is_scalar($selector) )
        {
            $this->selector = json_encode($selector);
        }
        else
        {
            $this->selector = Buffering\Callback::do($selector);
        }
        

        return $this;
    }
417999
public function selector2xpath($selector)
    {
        $parts = preg_split('/\\s+/', $selector);
        $xpath = "";
        foreach ($parts as $part) {
            if (preg_match('/^([A-Za-z][A-Za-z0-9]*)/', $part, $matches)) {
                $xpath .= "//$matches[1]";
            } else {
                $xpath .= "//*";
            }
            $xfilters = array();
            if (preg_match('/#([^#.\[]+)/', $part, $matches)) {
                $xfilters[] = "@id='$matches[1]'";
            }
            if (preg_match('/\.([^#.\[]+)/', $part, $matches)) {
                $xfilters[] = "contains(@class,'$matches[1]')";
            }
            if ($xfilters) {
                $xpath .= '[' . implode(',', $xfilters) . ']';
            }
        }
        return $xpath;
    }
1333152
protected function match($selector)
    {
        if (is_array($selector)) {
            return $this->strictMatch($selector);
        }

        if (Locator::isCSS($selector)) {
            return $this->getCrawler()->filter($selector);
        }
        if (Locator::isXPath($selector)) {
            return $this->getCrawler()->filterXPath($selector);
        }
        throw new MalformedLocatorException($selector, 'XPath or CSS');
    }