How can I work with Google / Auth accounts using Protractor & Webdriver?

Our application uses Google accounts for authorization / authentication, and you usually access the application by doing the following:

  • Go to or go there
  • Sign in to your account
  • Visit our app (assuming you've previously accepted the app permissions) and you're signed in

When I recreate these steps using Protractor (using WebDriverJS, Chromedriver, selenium, etc.), the browser β€œforgot” that you were previously logged into your Google account and our application is preventing your access.

From what I understand, this is because each test uses a new instance of the browser, so after each google account logs in / navigate to our app step (i.e. broswer.get('');

) the browser session is not saved.

How can we reuse the browser to prevent this from happening?

Note. I've already tried a flag --user-data-dir

that has no effect. Also we do not use Karma or Jasmine and use the cucumber support provided by the Transporter.

Sample code:

this.Given(/^I'm logged into my Google Account$/, function (callback) {
  var dvr = browser.driver;

this.When(/^I navigate to our App$/, function (callback) {

this.Then(/^I am logged in to our App$/, function (callback) {



source to share

All Articles