public function NamedSelector::translateToXPath in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/behat/mink/src/Selector/NamedSelector.php \Behat\Mink\Selector\NamedSelector::translateToXPath()
Translates provided locator into XPath.
Parameters
string|array $locator selector name or array of (selector_name, locator):
Return value
string
Throws
\InvalidArgumentException
Overrides SelectorInterface::translateToXPath
File
- vendor/
behat/ mink/ src/ Selector/ NamedSelector.php, line 200
Class
- NamedSelector
- Named selectors engine. Uses registered XPath selectors to create new expressions.
Namespace
Behat\Mink\SelectorCode
public function translateToXPath($locator) {
if (2 < count($locator)) {
throw new \InvalidArgumentException('NamedSelector expects array(name, locator) as argument');
}
if (2 == count($locator)) {
$selector = $locator[0];
$locator = $locator[1];
}
else {
$selector = (string) $locator;
$locator = null;
}
if (!isset($this->selectors[$selector])) {
throw new \InvalidArgumentException(sprintf('Unknown named selector provided: "%s". Expected one of (%s)', $selector, implode(', ', array_keys($this->selectors))));
}
$xpath = $this->selectors[$selector];
if (null !== $locator) {
$xpath = strtr($xpath, array(
'%locator%' => $this
->escapeLocator($locator),
));
}
return $xpath;
}