Skip to content

Commit 5deb56c

Browse files
authored
Merge pull request #631 from eiriksm/feat/helper-for-submit
Add a helper for the getting of the login submit element
2 parents 5ee222f + 9d781dc commit 5deb56c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Drupal/DrupalExtension/Manager/DrupalAuthenticationManager.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Drupal\DrupalExtension\Manager;
44

5+
use Behat\Mink\Element\DocumentElement;
56
use Behat\Mink\Exception\DriverException;
67
use Behat\Mink\Mink;
78
use Drupal\Driver\AuthenticationDriverInterface;
@@ -52,6 +53,14 @@ public function __construct(Mink $mink, DrupalUserManagerInterface $drupalUserMa
5253
$this->setDrupalParameters($drupalParameters);
5354
}
5455

56+
/**
57+
* Helper to get the element we want to use for submitting the login form.
58+
*/
59+
protected function getLoginSubmitElement(DocumentElement $element)
60+
{
61+
return $element->findButton($this->getDrupalText('log_in'));
62+
}
63+
5564
/**
5665
* {@inheritdoc}
5766
*/
@@ -64,7 +73,7 @@ public function logIn(\stdClass $user)
6473
$element = $this->getSession()->getPage();
6574
$element->fillField($this->getDrupalText('username_field'), $user->name);
6675
$element->fillField($this->getDrupalText('password_field'), $user->pass);
67-
$submit = $element->findButton($this->getDrupalText('log_in'));
76+
$submit = $this->getLoginSubmitElement($element);
6877
if (empty($submit)) {
6978
throw new \Exception(sprintf("No submit button at %s", $this->getSession()->getCurrentUrl()));
7079
}

0 commit comments

Comments
 (0)