public function VarbaseContext::iAmLoggedInUserWithTheUsernameAndPassword in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 9.0.x
Same name and namespace in other branches
- 8.8 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iAmLoggedInUserWithTheUsernameAndPassword()
- 8.4 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iAmLoggedInUserWithTheUsernameAndPassword()
- 8.5 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iAmLoggedInUserWithTheUsernameAndPassword()
- 8.6 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iAmLoggedInUserWithTheUsernameAndPassword()
- 8.7 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iAmLoggedInUserWithTheUsernameAndPassword()
Authenticate a user with a given username and password on the spot.
Varbase Context #varbase.
Example: I am a logged in user with the username "testing" and password "testing user password"
@Given /^I am a logged in user with (?:|the )username "(?P<username>[^"]*)" and password "(?P<password>[^"]*)"$/
File
- tests/
features/ bootstrap/ VarbaseContext.php, line 113
Class
- VarbaseContext
- Defines application features from the specific context.
Code
public function iAmLoggedInUserWithTheUsernameAndPassword($username, $password) {
// Logout if I am logged in.
if ($this
->loggedIn()) {
$this
->logout();
}
// Login with the.
$this
->getSession()
->visit($this
->locatePath('/user/login'));
$page = $this
->getSession()
->getPage();
if ($this
->matchingElementAfterWait('css', '[data-drupal-selector="edit-name"]', 6000)) {
$page
->fillField('name', $username);
$page
->fillField('pass', $password);
$submit = $page
->findButton('op');
$submit
->click();
}
}