Running into Error while waiting for Protractor to sync with the page with basic protractor test

前端 未结 7 1992
南旧
南旧 2020-12-03 10:31
describe(\'my homepage\', function() {
    var ptor = protractor.getInstance();
    beforeEach(function(){
        // ptor.ignoreSynchronization = true;
        ptor         


        
7条回答
  •  抹茶落季
    2020-12-03 11:07

    I was getting this error:

    Failed: Error while waiting for Protractor to sync with the page: "window.angular is undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"

    The solution was to call page.navigateTo() before page.getTitle().

    Before:

    import { AppPage } from './app.po';
    
    describe('App', () => {
      let page: AppPage;
    
      beforeEach(() => {
        page = new AppPage();
      });
    
      it('should have the correct title', () => {
        expect(page.getTitle()).toEqual('...');
      })
    });
    

    After:

    import { AppPage } from './app.po';
    
    describe('App', () => {
      let page: AppPage;
    
      beforeEach(() => {
        page = new AppPage();
        page.navigateTo();
      });
    
      it('should have the correct title', () => {
        expect(page.getTitle()).toEqual('...');
      })
    });
    

提交回复
热议问题