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 accounts.google.com 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('ourappurl.com');
) 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;
dvr.get('https://accounts.google.com');
dvr.findElement(by.id('Email')).sendKeys('test.account@testaccount.com');
dvr.findElement(by.id('next')).click();
dvr.findElement(by.id('Passwd')).sendKeys('password');
dvr.findElement(by.id('signIn')).click().then(callback);
});
this.When(/^I navigate to our App$/, function (callback) {
browser.get('/').then(callback);
});
this.Then(/^I am logged in to our App$/, function (callback) {
checkUserLoggedIn().then(callback);
});
source to share
No one has answered this question yet
Check out similar questions: