Format the given selector with the current prefix.

@param  string  $selector
@return string
426159
public function format($selector)
    {
        $sortedElements = collect($this->elements)->sortByDesc(function ($element, $key) {
            return strlen($key);
        })->toArray();

        $selector = str_replace(
            array_keys($sortedElements), array_values($sortedElements), $originalSelector = $selector
        );

        if (Str::startsWith($selector, '@') && $selector === $originalSelector) {
            $selector = '[dusk="'.explode('@', $selector)[1].'"]';
        }

        return trim($this->prefix.' '.$selector);
    }
424259
public function prev($selector=null)
    {
        $result = $this->createChildInstance();

        if (isset($this->document) && $this->length > 0) {
            foreach ($this->nodes as $node) { // get all previous sibling of all nodes
                if ($prev = self::getPreviousElement($node)) {
                    $result->addDomNode($prev);
                }
            }

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

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

        return [];
    }
1161369
protected function getTable($selector) {
        $selector = $this->getSession()->getSelectorsHandler()->xpathLiteral($selector);
        $page = $this->getSession()->getPage();
        $candidates = $page->findAll(
            'xpath',
            $this->getSession()->getSelectorsHandler()->selectorToXpath(
                "xpath", ".//table[(./@id = $selector or  contains(./@title, $selector))]"
            )
        );

        // Find tables by a <caption> field
		$candidates += $page->findAll('xpath', "//table//caption[contains(normalize-space(string(.)), 
			$selector)]/ancestor-or-self::table[1]");

        // Find tables by a .title node
		$candidates += $page->findAll('xpath', "//table//*[@class='title' and contains(normalize-space(string(.)), 
			$selector)]/ancestor-or-self::table[1]");

        // Some tables don't have a visible title, so look for a fieldset with data-name instead
        $candidates += $page->findAll('xpath', "//fieldset[@data-name=$selector]//table");

        assertTrue((bool)$candidates, 'Could not find any table elements');

        $table = null;
        foreach($candidates as $candidate) {
            if(!$table && $candidate->isVisible()) {
                $table = $candidate;
            }
        }

        assertTrue((bool)$table, 'Found table elements, but none are visible');

        return $table;
    }
1103449
public function formatHeaderAndRemovePrefix($header, $prefix = 'HTTP_') {
        if (str_starts_with($header, $prefix)) {
            $header = substr($header, strlen($prefix));
        }

        return $this->formatHeader($header);
    }
978687
public static function prefix($prefix = null)
	{
		if(null !== $prefix)
		{
			self::$prefix = $prefix;
		}
		return self::$prefix;
	}
364734
public function parent($selector = null) {
        $results = $this->_walkPathUntil('parentNode', null, $selector, self::$MATCH_TYPE_FIRST);

        return $this->result($results);
    }
431024
public function applyRule($selector, $style)
    {
        if($selector) {
            $nodes = $this->_getNodesForCssSelector($selector);
            $style = $this->_styleToArray($style);

            foreach($nodes as $node) {
                $current = $node->hasAttribute("style") ?
                    $this->_styleToArray($node->getAttribute("style")) :
                    array();

                $current = $this->_mergeStyles($current, $style);

                $node->setAttribute("style", $this->_arrayToStyle($current));
            }
        }

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

        return $this->findXPath($converter->toXPath($selector, $prefix));
    }
273901
private function getCssSelectorPrecedence($selector)
    {
        $selectorKey = md5($selector);
        if (!isset($this->caches[self::CACHE_KEY_SELECTOR][$selectorKey])) {
            $precedence = 0;
            $value = 100;
            // ids: worth 100, classes: worth 10, elements: worth 1
            $search = ['\\#', '\\.', ''];

            foreach ($search as $s) {
                if (trim($selector) === '') {
                    break;
                }
                $number = 0;
                $selector = preg_replace('/' . $s . '\\w+/', '', $selector, -1, $number);
                $precedence += ($value * $number);
                $value /= 10;
            }
            $this->caches[self::CACHE_KEY_SELECTOR][$selectorKey] = $precedence;
        }

        return $this->caches[self::CACHE_KEY_SELECTOR][$selectorKey];
    }
114767
public function append($selector, $type){
		$this->selector			= clone $selector;
		$this->selector->parent	= $this;
		$this->selector->type	= $type;
		
		return $this->selector;
	}
1211587
public function mouseover(string $selector = null): Element
    {
        if ($selector === null) {
            $element = $this->remote;
        } else {
            $element = $this->resolver->findOrFail($selector);
        }

        $this->driver->getMouse()->mouseMove($element->getCoordinates());

        return $this;
    }
234250
private function fetchCssExpression($selector, $prefix = '//')
    {
        $pos = strrpos($selector, '::');

        if ($pos !== false) {
            $property = substr($selector, $pos + 2);
            $property = $this->fetchCssProperty($property);
            $property = $this->parseCssProperty($property[ 'name' ], $property[ 'args' ]);

            $selector = substr($selector, 0, $pos);
        }

        if (substr($selector, 0, 1) === '>') {
            $prefix = '/';

            $selector = ltrim($selector, '> ');
        }

        $segments = $this->getSelectorSegments($selector);
        $expression = '';

        while (count($segments) > 0) {
            $expression .= $this->generateExpression($segments, $prefix);

            $selector = trim(substr($selector, strlen($segments[ 'selector' ])));
            $prefix = isset($segments[ 'rel' ]) ? '/' : '//';

            if ($selector === '') {
                break;
            }

            $segments = $this->getSelectorSegments($selector);
        }

        if (isset($property)) {
            $expression = $expression . '/' . $property;
        }

        return $expression;
    }
1293820
public function getFirstMatchingField ($selector)
    {
        $fields = $this->getFields($selector);
        if (empty($fields)) {
            return null;
        } else {
            return reset($fields);
        }
    }
122887
public function setSelector( $selector )
    {
        $this->selector = empty( $selector )
            ? self::SELECTOR_ALL
            : (string) $selector;

        $matches = array();

        if ( empty( $this->rootParagraphId ) &&
             preg_match( '/#paragraph-(\d+)/', $selector, $matches ) )
        {
            $this->setRootParagraphId( $matches[1] );
        }

        return $this;
    }
782446
private function prefix($prefix)
    {
        if ($prefix) {
            $prefixLastChar = substr($prefix, -1);

            if ($prefixLastChar != '.' && $prefixLastChar != ':') {
                $prefix .= '.';
            }
        }

        return $prefix;
    }
311770
protected function formatUrl($url)
    {
        $uri = !is_null($this->prefixUrl) ? $this->prefixUrl . $url : $url;

        return $uri == '/' ? '/' : ltrim(rtrim($uri, '/'), '/');
    }