简体   繁体   English

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

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

I'm trying to follow the Protractor's tutorial on Protractors official site but I can't even complete the step 0. 我正在尝试在Protractors官方网站上关注量角器的教程,但我甚至无法完成第0步。

I'm using protractor & webdriver-manager in version 6.0.0. 我在6.0.0版本中使用了protractor和webdriver-manager。 My SO is Linux (Ubuntu 18.06) and my Chrome is the latest available (73.0.3683.86). 我的SO是Linux(Ubuntu 18.06),我的Chrome是最新的(73.0.3683.86)。 After installing protractor I had to downgrade the chromedriver installed by default as it expected me to have Chrome 74. I downgraded it by executing webdriver-manager --versions.chrome 73.0.3683.68 . 在安装量角器后,我不得不降级默认安装的chromedriver,因为它希望我有Chrome 74.我通过执行webdriver-manager --versions.chrome 73.0.3683.68降级它。

After that, I have been following the step 0 of the tutorial. 之后,我一直在关注本教程的第0步。 I have the configuration.js file and the test-spec.js files as follow: 我有configuration.js文件和test-spec.js文件如下:

configuration.js configuration.js

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

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');
    });
});

When I run protactor protractor configuration.js I'm getting the following error: 当我运行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)

Updating this answer 更新此答案

Protractor version 6.0 uses selenium version 4 which is the first selenium version to drop support for the control flow. Protractor 6.0版使用selenium版本4 ,这是第一个不再支持控制流的selenium版本。 The control flow was what allowed Protractor to execute code like 控制流程允许Protractor执行类似的代码

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

in a synchronous manner. 以同步方式。

The control flow was used until now in order to handle the asynchronous nature of webdriverJS's promises in a user-friendly manner. 到目前为止使用控制流程是为了以用户友好的方式处理webdriverJS的承诺的异步性质。 Once the es8 async/await style of promise handling became supported however the decision was made to deprecate the control flow and advise users to leverage async/await going forward. 一旦es8异步/等待承诺处理方式得到支持,就决定弃用控制流并建议用户利用async / await继续前进。


original answer 原始答案

6.0 is the latest version of Protractor, I believe it was released 3 days ago (around 22/March/19), and it drops support for the control flow which was previously enabled by default. 6.0是Protractor的最新版本 ,我相信它是在3天前发布的(大约22 / March / 19),并且它不再支持以前默认启用的控制流程。 Apparently the tutorial documentation has not been updated to reflect this however and I believe this is why you are seeing this issue. 显然,教程文档尚未更新以反映这一点,我相信这就是您遇到此问题的原因。

Going forward you will need to use the async/await syntax (which is actually much more readable and easy to use in my opinion) 继续前进,您将需要使用async / await语法(在我看来,它实际上更易读和易用)

Try the following code: 请尝试以下代码:

configuration.js configuration.js

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

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'); }); }); 

Update: If you try adding SELENIUM_PROMISE_MANAGER: true, to your configuration.js that may allow you to proceed with the demo as it is written. 更新:如果您尝试将SELENIUM_PROMISE_MANAGER: true,添加到您的configuration.js ,这可能允许您在编写时继续演示。

暂无
暂无

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

相关问题 等待量角器与页面同步时出错:在运行量角器测试用例时“在窗口中找不到角度” - Error while waiting for Protractor to sync with the page: “angular could not be found on the window” on running protractor test case 在等待量角器与页面同步时刷新时发生错误,在捕获警报时 - Error while waiting for protractor to sync with the page on catching alert during refresh 失败:等待量角器与页面同步时出错:“在窗口中找不到角度” - Failed: Error while waiting for Protractor to sync with the page: “angular could not be found on the window” 带有 protractorjs 的 Angular 2 失败:等待 Protractor 与页面同步时出错:“window.getAllAngularTestabilities 不是函数” - Angular 2 with protractorjs Failed: Error while waiting for Protractor to sync with the page: "window.getAllAngularTestabilities is not a function" 执行量角器测试时出现“失败:等待量角器与页面同步时出错” - "Failed: Error while waiting for Protractor to sync with the page" while executing Protractor tests 使用量角器时,单击导致发出http请求的按钮时,我收到此消息:等待量角器同步时出错 - While using Protractor, when clicking a button which causes an http request to be made, I receive this: error while waiting for protractor to sync 量角器不等待页面加载 - Protractor not waiting for page load 使用$ resource时,量角器会等待与页面同步 - Protractor times out waiting for sync with page when using $resource Protractor.js:加载页面时出错 - Protractor.js:Error while loading the page 不稳定打开新页面量角器非角形部位 - Instability opening new page Protractor non angular site
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM