public function fillLoginForm(array $props, $message = '')
    {
        $this->visitPath('/user/login');
        $formContext = $this->getFormContext();

        foreach (['username', 'password'] as $prop) {
            $formContext->fillField($this->getDrupalText($prop . '_field'), $props[$prop]);
        }

        $this->getWorkingElement()->pressButton($this->getDrupalText('log_in'));

        if (!$this->isLoggedIn()) {
            if (empty($message)) {
                $message = sprintf(
                    'Failed to login as a user "%s" with password "%s".',
                    $props['username'],
                    $props['password']
                );
            }

            throw new \Exception($message);
        }

        $GLOBALS['user'] = $this->user = user_load_by_name($props['username']);
    }
public function fillLoginForm(array $props, $message = '')
    {
        $this->visitPath('/user/login');
        $formContext = $this->getFormContext();

        foreach (['username', 'password'] as $prop) {
            $formContext->fillField($this->getDrupalText($prop . '_field'), $props[$prop]);
        }

        $this->getWorkingElement()->pressButton($this->getDrupalText('log_in'));

        if (!$this->isLoggedIn()) {
            if (empty($message)) {
                $message = sprintf(
                    'Failed to login as a user "%s" with password "%s".',
                    $props['username'],
                    $props['password']
                );
            }

            throw new \Exception($message);
        }

        $GLOBALS['user'] = $this->user = user_load_by_name($props['username']);
    }
@param array $props
An array with two keys: "username" and "password". Both of them are required.
@param string $message
An error message, that will be thrown when user cannot be authenticated.

@throws \Behat\Mink\Exception\ElementNotFoundException
When one of a fields cannot be not found.
@throws \Exception
When login process failed.
@throws \WebDriver\Exception\NoSuchElement
When log in button cannot be found.