我们有一个场景,其中Login Page是一个非Angular页面,并在成功登录后调出Angular Application . 登录后,我们的应用程序正在手动启动捆绑文档就绪状态,并将ng-app与文档元素相关联 .

我们的测试场景是,登录(doLogin) - >做一些事务(doTransaction)

  • 我们在“OnPrepare”方法中使用ignoreSynchronization设置为true . 接下来,在测试中,我们执行了登录操作并在后登录页面(预期条件)中同步到元素 .

  • 在此期间,必须初始化Angular /正在初始化过程中 . 但是Protractor应该忽略这个过程,因为忽略了我设置的Flag .

  • 下一步,我点击了TransactionElement . 从这里开始,一切都应该是Angular,我们希望Protractor能够绑定它 . 因此,我们将ignoreSynchronization设置为false .

在这整个场景中,在第1步之后,我收到此错误,声明“ Error while waiting for Protractor to sync with the page: "parent (body) has no injector. this may mean it is not inside ng-app ” .

问题是, ignoreSynchronization 到那时仍然是真的 . 当我将其设置为忽略时,为什么Protractor会报告它正在尝试同步?欢迎任何想法 .

这是一段代码片段 .

OnPrepare Method

onPrepare: function(){
      console.log("**In On Prepare Method**");
      global.sel = browser.driver;
      browser.ignoreSynchronization = true;
      }

AngularPage.prototype.doLogin = function(){
                                   this.login.sendKeys(this.user);       
                                   this.password.sendKeys(this.passwd);  
                                   this.goButton.click();
                         browser.wait(this.EC.elementToBeClickable(this.TransactionElement));                                  
                                };

AngularPage.prototype.doTransaction = function(){
                                   browser.wait(this.EC.elementToBeClickable(this.TransactionElement)).then(this.TransactionElement.click());    
                                   browser.ignoreSynchronization = false; 
                                };

Locator of the Transaction Element - element(by.xpath('//*[@id= 1453864 ]/ul[1]/li[2]/a/span[1]'));