简体   繁体   中英

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.

I'm using protractor & webdriver-manager in version 6.0.0. My SO is Linux (Ubuntu 18.06) and my Chrome is the latest available (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 .

After that, I have been following the step 0 of the tutorial. I have the configuration.js file and the test-spec.js files as follow:

configuration.js

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

test-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:

[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. The control flow was what allowed Protractor to execute code like

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. 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.


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. 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)

Try the following code:

configuration.js

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

test-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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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