adnan2nd
adnan2nd

Reputation: 2211

Protractor not finding an element in angular 6 app

content in project.po.ts ->

newProjectButton() {
  return element(by.id('new-project'));
}

newProjectButtonText() {
  return this.newProjectButton().getText();
}

contents in spec file ->

describe('Projects', function () {
 let page: RMLProjectsPage;
 page = new RMLProjectsPage();  

 it('should create new project and its first workspace', () => {

   page.navigateToProjectsPage();

   expect(page.newProjectButtonText()).toEqual('New Project');

   ...

The test runs and a login test passes prior to this test. However, after it successfully navigates to projects page, it cannot find the new-project button. error is Failed: No element found using locator: By(css selector, *[id="new-project"])

Now if I put browser.ignoreSynchronization = true; after page construction , it finds that button, but it makes other query in a reactive form to fail. In an angular app we should not do browser.ignoreSynchronization = true; right? What am I missing here ...?

Upvotes: 0

Views: 519

Answers (1)

Madhan Raj
Madhan Raj

Reputation: 1442

browser.ignoreSynchronization = true; is deprectaed try browser.waitForAngularEnabled(false);.

To answer your question, if you make browser.waitForAngularEnabled(true); then you are asking protractor to wait until all the http requests are completed. If your application has a continuous network calls then there browser.waitForAngularEnabled(false); comes into picture.

Note: If you are using browser.waitForAngularEnabled(false); then you have to using explicit waits.

Hope the answer helps you.

For more info refer https://www.protractortest.org/#/timeouts

Upvotes: 2

Related Questions