繁体   English   中英

量角器“等待量角器与页面同步时出错”浏览Angular站点

[英]Protractor “Error while waiting for Protractor to sync with the page” browsing Angular site

我正在尝试在Protractors官方网站上关注量角器的教程,但我甚至无法完成第0步。

我在6.0.0版本中使用了protractor和webdriver-manager。 我的SO是Linux(Ubuntu 18.06),我的Chrome是最新的(73.0.3683.86)。 在安装量角器后,我不得不降级默认安装的chromedriver,因为它希望我有Chrome 74.我通过执行webdriver-manager --versions.chrome 73.0.3683.68降级它。

之后,我一直在关注本教程的第0步。 我有configuration.js文件和test-spec.js文件如下:

configuration.js

 exports.config = {
      seleniumAddress: 'http://localhost:4444/wd/hub',
      specs: ['test-spec.js']
    };

测试spec.js

describe('Protractor Demo App', function() {
    it('should have a title', function() {
        browser.get('http://juliemr.github.io/protractor-demo/');
        expect(browser.getTitle()).toEqual('Super Calculator');
    });
});

当我运行protactor protractor configuration.js我收到以下错误:

[15:15:13] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
DEPRECATION: Setting randomizeTests directly is deprecated, please use the random option in `configure`
DEPRECATION: Setting specFilter directly on Env is deprecated, please use the specFilter option in `configure`
Started
F

Failures:
1) Protractor Demo App should have a title
  Message:
    Expected [object Promise] to equal 'Super Calculator'.
  Stack:
    Error: Expected [object Promise] to equal 'Super Calculator'.
        at 
        at UserContext. (/home/srubio/Escritorio/Protractor/test-spec.js:5:32)
        at 

1 spec, 1 failure
Finished in 0.009 seconds
/home/srubio/n/lib/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:3190
        throw arguments[0];
        ^

Error: 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"
    at ProtractorBrowser. (/home/srubio/n/lib/node_modules/protractor/built/browser.js:354:27)
    at Generator.next ()
    at fulfilled (/home/srubio/n/lib/node_modules/protractor/built/browser.js:4:58)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)

更新此答案

Protractor 6.0版使用selenium版本4 ,这是第一个不再支持控制流的selenium版本。 控制流程允许Protractor执行类似的代码

browser.get('http://google.com');
expect(browser.getTitle()).toEqual('Super Calculator');

以同步方式。

到目前为止使用控制流程是为了以用户友好的方式处理webdriverJS的承诺的异步性质。 一旦es8异步/等待承诺处理方式得到支持,就决定弃用控制流并建议用户利用async / await继续前进。


原始答案

6.0是Protractor的最新版本 ,我相信它是在3天前发布的(大约22 / March / 19),并且它不再支持以前默认启用的控制流程。 显然,教程文档尚未更新以反映这一点,我相信这就是您遇到此问题的原因。

继续前进,您将需要使用async / await语法(在我看来,它实际上更易读和易用)

请尝试以下代码:

configuration.js

 exports.config = { seleniumAddress: 'http://localhost:4444/wd/hub', specs: ['test-spec.js'] }; 

测试spec.js

 describe('Protractor Demo App', function() { it('should have a title', async function() { await browser.get('http://juliemr.github.io/protractor-demo/'); expect(await browser.getTitle()).toEqual('Super Calculator'); }); }); 

更新:如果您尝试将SELENIUM_PROMISE_MANAGER: true,添加到您的configuration.js ,这可能允许您在编写时继续演示。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM