title: e2e how to test login sucess case in angular protractor
body: <p>Just started with e2e and I want to test the login success case in Angular app. So here is my test case</p>
  
  <pre><code>it("when login is successful — user object should be set in storage", () =&gt; {
          loginPage.fillCredentials();
  
          // wait until redirected to new lage
          const EC = protractor.ExpectedConditions;
          const elm = element(by.css(".logo-text"));
          browser.wait(EC.presenceOf(elm), 40000);
          expect(loginPage.getLocalStorageObject("currentUser")).toBeDefined();
          const currentUser = JSON.parse(loginPage.getLocalStorageObject("currentUser"));
          expect(currentUser.CarrierId).toBeDefined();
      });
  </code></pre>
  
  <p>And</p>
  
  <pre><code>fillCredentials(credentials: any = this.credentials): any {
     this.getFormField("email").sendKeys(credentials.userName);
     this.getFormField("password").sendKeys(credentials.password);
     element(by.css("button[aria-label='Login']")).click();
  }
  
  getLocalStorageObject(key): any {
      browser.executeScript(`return window.localStorage.getItem('${key}');`);
  }
  </code></pre>
  
  <p>I am providing the correct user credentials and then hit login button. </p>
  
  <p>In the app when login is done with correct credentials it sets the <code>currectUser</code> object in <code>localStorage</code> and redirect to page that is returned from the login page.</p>
  
  <p>But my test case is getting failed</p>
  
  <pre><code>when login is successful — user object should be set in storage
        - Expected undefined to be defined.
  </code></pre>
  
  <p>I am using wait function like this in <code>it</code></p>
  
  <pre><code>const EC = protractor.ExpectedConditions;
  const elm = element(by.css(".logo-text"));
  browser.wait(EC.presenceOf(elm), 40000);
  </code></pre>
  
  <p>where <code>.logo-text</code> class is the element present on the redirected page. </p>
  
  <p>Is this the right approach or something else needs to done?</p>