Protractor element finder is not getting element

  angular, e2e-testing, jasmine, protractor

I run an Angular 6 e2e using protractor.
It logs in just fine, but in the callback it doesn’t click the button even though it’s there.

describe('my test', () => {
  let loginPage: LoginPage;
  beforeEach(() => {
    loginPage = new LoginPage();
  });

  // #1 login test
  it('should open modal in desktop', () => {
    loginPage.login(environment.e2e.user.phone, environment.e2e.user.password);
    loginPage.verifySuccessfullLogin().then(() => {

      console.log('After verifySuccessfullLogin');
      await browser.sleep(1000);
      console.log('after waiting 1000 ms');
      
      //At this point I can see the button in the browser
      const btn = element(by.id('sendCheckBtnDesktop'));

      //Nothing from the following is working
      btn.click();
      console.log(btn.getText());
      console.log(btn.getId());
      console.log(btn.getTagName());
      console.log(btn);

    });

  });
});

The Html:

<button id="sendCheckBtnDesktop" _ngcontent-c8="" class="btn btn-lg btn-primary col-3 ng-star inserted"
  ><span _ngcontent-c8="">Open</span>
</button>

Source: Angular Questions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.