diff --git a/src/Drupal/DrupalExtension/Manager/DrupalAuthenticationManager.php b/src/Drupal/DrupalExtension/Manager/DrupalAuthenticationManager.php index abe85676..2b5ee3f3 100644 --- a/src/Drupal/DrupalExtension/Manager/DrupalAuthenticationManager.php +++ b/src/Drupal/DrupalExtension/Manager/DrupalAuthenticationManager.php @@ -2,6 +2,7 @@ namespace Drupal\DrupalExtension\Manager; +use Behat\Mink\Element\DocumentElement; use Behat\Mink\Exception\DriverException; use Behat\Mink\Mink; use Drupal\Driver\AuthenticationDriverInterface; @@ -52,6 +53,14 @@ public function __construct(Mink $mink, DrupalUserManagerInterface $drupalUserMa $this->setDrupalParameters($drupalParameters); } + /** + * Helper to get the element we want to use for submitting the login form. + */ + protected function getLoginSubmitElement(DocumentElement $element) + { + return $element->findButton($this->getDrupalText('log_in')); + } + /** * {@inheritdoc} */ @@ -64,7 +73,7 @@ public function logIn(\stdClass $user) $element = $this->getSession()->getPage(); $element->fillField($this->getDrupalText('username_field'), $user->name); $element->fillField($this->getDrupalText('password_field'), $user->pass); - $submit = $element->findButton($this->getDrupalText('log_in')); + $submit = $this->getLoginSubmitElement($element); if (empty($submit)) { throw new \Exception(sprintf("No submit button at %s", $this->getSession()->getCurrentUrl())); }