1

I have created a simple Angular portal page. On the main page there is a search bar where you can type name of some nba team such as "chicago bulls", "Indiana pacers", etc. After you type the team name and hit submit. You are redirected to the 2nd page where you can read a summary on the team you typed.

I am using angular js and protractor to test my pages. On the first page I did a simple test which passed . I checked simply the title tag is correct

it('should have a title', function() {
    browser.get('http://localhost:3000/');

    expect(browser.getTitle()).toEqual('NBA | NBA SUMMARY');
  });

The title should also be the same on the 2nd page. So i did the following test to check that. I typed in some team name and clicked submit to get to the 2nd page. Here is my code

  it('Title should be consistent', function(){
    browser.get('http://localhost:3000/');
    element(by.css('input')).sendKeys('Chicago Bulls');
    element(by.css('button')).click();

    expect(browser.getTitle()).toEqual('NBA | NBA SUMMARY');
    });

However the 2nd test never ran and it timed out and I got the following message.

   Message:
     Timed out waiting for Protractor to synchronize with the page after 11 seco
nds. Please see https://github.com/angular/protractor/blob/master/docs/faq.md
   Stacktrace:
     undefined

Finished in 13.67 seconds
1 test, 1 assertion, 1 failure

Here is my conf.js file code

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['spec.js'],
  capabilities: {
    browserName: 'chrome'
  }
}

Am i missing something? Please advice.

user1010101
  • 2,062
  • 7
  • 47
  • 76
  • Is it an angular page opened after a click? – alecxe Jun 23 '15 at 13:38
  • @alecxe yes, on the first page you type team name and then you click on submit button which takes you to the next page where you can read summary on the team you had entered on the first page. – user1010101 Jun 23 '15 at 13:39

1 Answers1

1

Tweaking ignoreSynchronization should help here:

afterEach(function () {
  browser.ignoreSynchronization = false;
});

it('Title should be consistent', function(){
  browser.get('http://localhost:3000/');
  element(by.css('input')).sendKeys('Chicago Bulls');

  browser.ignoreSynchronization = true;
  element(by.css('button')).click();

  expect(browser.getTitle()).toEqual('NBA | NBA SUMMARY');
});
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • awesome it worked, I was wondering if you can briefly explain me what ignoresynchronization does? just for personal knowledge. Also i am a little confused about what is actually being synchronized? – user1010101 Jun 23 '15 at 13:50
  • 1
    @user1010101 glad it helped. Sure, please see: http://stackoverflow.com/questions/28808463/what-is-browser-ignoresynchronization-in-protractor. – alecxe Jun 23 '15 at 13:50
  • A friend of mine has a similar question as mine i told him to post it I gave him tips you did but he stuck and i think you can probably clarify his misunderstanding http://stackoverflow.com/questions/31077824/looping-over-the-map-function-in-protractor – user1010101 Jun 26 '15 at 16:20