Skip to content

Commit

Permalink
BUG FIXED: try to find field by label firstly and then - by named sel…
Browse files Browse the repository at this point in the history
…ector
  • Loading branch information
BR0kEN- committed Jan 12, 2016
1 parent 3abe444 commit 721b79e
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/Context/RawPageContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,20 @@ public function findField($selector)
{
$selector = ltrim($selector, '#');
$element = $this->getWorkingElement();
$field = $element->findField($selector);

if (null === $field) {
foreach ($this->findLabels($selector) as $forAttribute => $label) {
// We trying to find an ID with "-upload" suffix, because some
// image inputs in Drupal are suffixed by it.
foreach ([$forAttribute, "$forAttribute-upload"] as $elementID) {
$field = $element->findById($elementID);

if (null !== $field) {
return $field;
}

foreach ($this->findLabels($selector) as $forAttribute => $label) {
// We trying to find an ID with "-upload" suffix, because some
// image inputs in Drupal are suffixed by it.
foreach ([$forAttribute, "$forAttribute-upload"] as $elementID) {
$field = $element->findById($elementID);

if (null !== $field) {
return $field;
}
}
}

return $field;
return $element->findField($selector);
}

/**
Expand Down

0 comments on commit 721b79e

Please sign in to comment.