Skip to content

Instantly share code, notes, and snippets.

@polevaultweb
Last active February 17, 2020 12:46
Show Gist options
  • Save polevaultweb/e66b717b1c1937f31bd95e8d5f877722 to your computer and use it in GitHub Desktop.
Save polevaultweb/e66b717b1c1937f31bd95e8d5f877722 to your computer and use it in GitHub Desktop.
Using Codeception to login to Google and approve permissions during oAuth2 login flow.
<?php
$I->waitForText( 'Sign in with Google' );
$I->fillField('#identifierId', $_ENV['GOOGLE_EMAIL']);
$I->wait(1);
$I->click('#identifierNext');
$I->wait(1);
$I->fillField('password', $_ENV['GOOGLE_PASSWORD']);
$I->wait(1);
$I->click('#passwordNext');
$I->wait(2);
if ( $I->seeOnPage( 'Grant' ) ) {
$this->executeJS('return document.querySelectorAll("[data-custom-id=\"oauthScopeDialog-allow\"]")[0].click()');
$I->wait(1);
}
$I->click('#submit_approve_access');
@polevaultweb
Copy link
Author

polevaultweb commented Feb 17, 2020

Google account being used must allow less secure apps to sign in https://myaccount.google.com/u/3/lesssecureapps?pageId=none

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment