function BrowserKitDriver::getFieldPosition
Gets the position of the field node among elements with the same name
BrowserKit uses the field name as index to find the field in its Form object. When multiple fields have the same name (checkboxes for instance), it will return an array of elements in the order they appear in the DOM.
Throws
File
-
vendor/
behat/ mink-browserkit-driver/ src/ BrowserKitDriver.php, line 685
Class
- BrowserKitDriver
- Symfony BrowserKit driver.
Namespace
Behat\Mink\DriverCode
private function getFieldPosition(\DOMElement $fieldNode) : int {
$elements = $this->getCrawler()
->filterXPath('//*[@name=\'' . $fieldNode->getAttribute('name') . '\']');
if (count($elements) > 1) {
// more than one element contains this name !
// so we need to find the position of $fieldNode
foreach ($elements as $key => $element) {
/** @var \DOMElement $element */
if ($element->getNodePath() === $fieldNode->getNodePath()) {
return $key;
}
}
}
return 0;
}