Skip to content

Commit

Permalink
Update the login method to use findById and rename of the LoginForm t…
Browse files Browse the repository at this point in the history
…o MemberLoginForm
  • Loading branch information
Simon Erkelens committed Jun 4, 2017
1 parent 47bebe6 commit e40f0ee
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/Context/LoginContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,16 @@ public function stepILogInWith($email, $password)
$loginUrl = $c->joinUrlParts($c->getBaseUrl(), $c->getLoginUrl());
$this->getMainContext()->getSession()->visit($loginUrl);
$page = $this->getMainContext()->getSession()->getPage();
$forms = $page->findAll('xpath', '//form[contains(@action, "Security/LoginForm")]');
assertNotNull($forms, 'Login form not found');
$form = $page->findById('MemberLoginForm_LoginForm');
assertNotNull($form, 'Login form not found');

// Try to find visible forms again on login page.
$visibleForm = null;
/** @var NodeElement $form */
foreach ($forms as $form) {
if ($form->isVisible() && $form->find('css', '[name=Email]')) {
$visibleForm = $form;
}
if ($form->isVisible() && $form->find('css', '[name=Email]')) {
$visibleForm = $form;
}

assertNotNull($visibleForm, 'Could not find login form');
assertNotNull($visibleForm, 'Could not find login email field');

$emailField = $visibleForm->find('css', '[name=Email]');
$passwordField = $visibleForm->find('css', '[name=Password]');
Expand Down

0 comments on commit e40f0ee

Please sign in to comment.