Error while waiting for protractor to sync with page: "Unable to read property" get "of undefined"

My test landing page has SSO login built in. As soon as I get to the page, SSO integrates Windows Authentication and then navigates to the home page.

I tried to disable Sync and it works for the first test to check the header, but for the second test it will return an error unable to find the element and when I enable Sync it will return a sync error and undefined error.

describe('Test area to ', function () {

var menuObjects = require('../page/MenuObjects.js');

it('Verify Page Title', function () {
    menuObjects.setSyncOff(); 
    browser.get('/home/');
    expect(browser.getTitle()).toEqual('Home');
    browser.driver.sleep(3000);
});

it('Navigate ', function () {
    menuObjects.setSyncOn();
    menuObjects.menuButton.click();        
});
});

      

The error message for navigation is with menuObjects.setSyncOn ();

Error while waiting for Protractor to sync with the page: "Unable to read property 'get' from undefined"

The error message for navigation is with menuObjects.setSyncOff ();

NoSuchElementError: element not found using locator: By.id ("menu-link")

ng-app

included in a div inside the body:

<body style="width: 100%">
<div class="frame" style="width: 100%">
    <div class="container-fluid" style="width: 100%">
        <div class="" style="width: 100%">
            <div style="width: 100%">
                <!--_AngularBaseLayout: BEGIN-->                    

<div ng-app="myHomeApp" ng-cloak class="ng-cloak">
     <div ng-view id="ng-view"> </div>
</div>

      

Any suggestion?

+3


source to share


1 answer


If ng-app

not defined on html

or body

, you need to report protractor

it by setting the rootElement

configuration setting
:

exports.config = {
  seleniumAddress: env.seleniumAddress,

  baseUrl: env.baseUrl,

  ...

  // Selector for the element housing the angular app.
  rootElement: 'div#nested-ng-app'
};

      

This will make it unnecessary to turn sync on and off - the protractor will wait for angular to "calm down" before proceeding with further test execution.




If that doesn't help with the error NoSuchElementError

, you can explicitly expect the element to appear with presenceOf

Expected Condition
:

var EC = protractor.ExpectedConditions;

var elm = browser.wait(EC.presenceOf($('#menu-link')), 5000);

      

+2


source







All Articles