1
votes

I'm trying to set up Protractor for testing my application but it requires auth through gmail, and I'm stuck on trying to login:

describe('Vivace Home page', function() {

  var hasClass = function (element, cls) {
    return element.getAttribute('class').then(function (classes) {
      return classes.split(' ').indexOf(cls) !== -1;
    });
  };

  beforeEach(function() {

    browser.ignoreSynchronization = true;
    browser.get('/');

    var emailInput = browser.driver.findElement(by.id('Email'));
    emailInput.sendKeys('[email protected]')

    var nextButton = browser.driver.findElement(by.id('next'));

    nextButton.click().then(function() {
      browser.pause();
      var passwordInput = browser.driver.findElement(by.id('Passwd'));
      console.log(passwordInput);
      passwordInput.sendKeys('11111');
      // var signInButton = browser.driver.findElement(by.id('signIn'));
    })
  });

  it('should have the correct title', function() {
    expect(browser.getTitle()).toEqual('InRhythm - Vivace');
  });
});

I can see Protractor opening up the gmail page, inputting the email and clicking the next button, and when I do browser.pause I can actually see the password input with an id of "Passwd" right there on the page with inspector and yet I can't access it to complete my log in.

I get this error when I remove the browser.pause

Failed: no such element: Unable to locate element: {"method":"id","selector":"Passwd"}

1

1 Answers

2
votes

Wait for it to become visible:

var EC = protractor.ExpectedConditions;
var passwordInput = element(by.id('Passwd'));

browser.wait(EC.visibilityOf(passwordInput), 5000);
passwordInput.sendKeys('11111');