From 30d266fd9e7a314c12e0d0be54471c2290844e75 Mon Sep 17 00:00:00 2001 From: fumikito Date: Wed, 18 Oct 2017 20:43:39 +0900 Subject: [PATCH] Change login condition --- src/Context/RawWordPressContext.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Context/RawWordPressContext.php b/src/Context/RawWordPressContext.php index e25214e..6fbdfa2 100644 --- a/src/Context/RawWordPressContext.php +++ b/src/Context/RawWordPressContext.php @@ -114,12 +114,19 @@ public function login( $user, $password ) $submit->click(); for ( $i = 0; $i < $this->timeout; $i++ ) { + // Check if keeping staying on login page till timeout. try { - $admin_url = $this->get_admin_url() . '/'; - if ( $this->is_current_url( $admin_url ) ) { - return true; + if ( $this->is_current_url( '/wp-login.php' ) ) { + // Still in login page. + if ( $this->getSession()->getPage()->find( 'css','#login_error' ) ) { + // Find error dialog. Apparent Error. + return false; + } else { + // @todo Should consider other situations? + } } else { - return false; + // Redirected. Guess logged in. + return true; } } catch ( \Exception $e ) { // do nothing