【问题标题】:Error while waiting for Protractor to sync with the page等待量角器与页面同步时出错
【发布时间】:2018-12-07 20:13:26
【问题描述】:

我在 Protractor 中的测试有问题。

我需要这样的东西:

'找到 iframe,点击它,然后为 ng-model 设置值。'

所以我的代码看起来像:

browser.switchTo().frame(element(by.model('myModel')).getWebElement());
browser.findElement(by.className('testClass')).click();

var elm = element(by.model("myModel"));
elm.evaluate("fields.myModel = 'test';");

但不幸的是我有如下错误:

Failed: Error while waiting for Protractor to sync with the page: 
"both angularJS testability and angular testability are 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

这个页面是角页面,我不知道如何处理它。 我不能使用'browser.ignoreSynchronization = true',因为我有错误,那个角度没有定义。 我也无法刷新浏览器,因为那样我会丢失我的内容(点击后会显示),所以我不知道该怎么做。

非常感谢您提供的任何提示。

【问题讨论】:

    标签: angularjs protractor


    【解决方案1】:

    iframe 和量角器不能很好地相处。我使用browser.waitForAngularEnabled();,然后进行检查,然后切换回来。
    示例:

    browser.waitForAngularEnabled(false);
    browser.switchTo().frame(iFrame)
    //Do stuff inside iframe here. You should be treating this as a non angular page
    browser.switchTo().defaultContent();
    browser.waitForAngularEnabled(true);
    

    【讨论】:

    • 你不是说最后一行是真的吗?
    • @JeremyKahan 我的意思是真的,我已经编辑了答案。谢谢
    猜你喜欢
    • 2014-05-16
    • 2016-04-26
    • 2019-08-16
    • 2019-10-03
    • 2015-10-05
    • 2019-06-12
    • 2023-03-12
    • 2015-05-06
    • 1970-01-01
    相关资源
    最近更新 更多