Skip to content

Commit e38bbfa

Browse files
authored
Merge pull request #13 from fumikito/enhancement/change-loggedin-condition
Change login condition
2 parents 4bfbe9e + 30d266f commit e38bbfa

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/Context/RawWordPressContext.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,19 @@ public function login( $user, $password )
114114
$submit->click();
115115

116116
for ( $i = 0; $i < $this->timeout; $i++ ) {
117+
// Check if keeping staying on login page till timeout.
117118
try {
118-
$admin_url = $this->get_admin_url() . '/';
119-
if ( $this->is_current_url( $admin_url ) ) {
120-
return true;
119+
if ( $this->is_current_url( '/wp-login.php' ) ) {
120+
// Still in login page.
121+
if ( $this->getSession()->getPage()->find( 'css','#login_error' ) ) {
122+
// Find error dialog. Apparent Error.
123+
return false;
124+
} else {
125+
// @todo Should consider other situations?
126+
}
121127
} else {
122-
return false;
128+
// Redirected. Guess logged in.
129+
return true;
123130
}
124131
} catch ( \Exception $e ) {
125132
// do nothing

0 commit comments

Comments
 (0)