0

I am using protractor to test a Non-Angular app and when I use the browser.forkNewDriverInstance() then it seems browser.forkNewDriverInstance() is no longer working correctly since I get this error when executing:

Failed: Error while waiting for Protractor to sync with the page: "window.angular is undefined.  This could be either beca use this is a

non-angular page or because your test involves client-side navigation, which can interfere with Protractor's boo tstrapping. See http://git.io/v4gXM for details"

here the code:

conf.js

exports.config = {
  framework: 'jasmine',
  specs: ['test.js','chat_featuresx.js'],
  multiCapabilities: [{
    browserName: 'chrome'
  }],
  directConnect: 'true'
}

test.js

describe('First interaction customer-agent', () => {

    beforeEach(function() {
        global.agent = browser;
        global.customer = browser.forkNewDriverInstance();
        agent.ignoreSynchronization = true;
        customer.ignoreSynchronization = true;
        agent.get('http://engager-stage.brandembassy.com/');
        customer.get('https://vps-web-utils.awsbrandembassy.com/livechat-window-gherkin/');
        agent.driver.manage().window().maximize();
        customer.driver.manage().window().maximize();
    });

    it('should be seen offline when agent is offline and viceversa', () => {      
        // check that default status is minimized 
        browser.sleep(2000);
        expect(customer.isElementPresent(by.css('.be-chat.be-chat--minimize'))).toBe(true);       
    });
});
SimoneB
  • 158
  • 2
  • 12
  • so, not sure if you can do this, but can you set your config for `ignoreSynchronization` BEFORE forking, then your forked browser will assume that config option? – LostJon May 08 '17 at 18:19
  • Why would you fork your browser and not use the default `browser`-object? If you use the default implementation of Protractor you can add the `browser.ignoreSynchronization = true;` in the `onPrepare` in your config an just use the default syntax of Protractor. Otherwise you can go with what @Paul Co suggests – wswebcreation May 08 '17 at 19:05

1 Answers1

1

After checking the code. Few things that I saw are:
1. If you declare a variable as global, I think you need to include it when using them.
e.g. global.agent.ignoreSynchronization
2. isElementPresent seems to be used for angular pages.
In your case, I replaced it with isPresent

Please see sample code below:

describe('First interaction customer-agent', () => {
    var agent = browser;
    var customer = browser.forkNewDriverInstance();

    beforeEach(function() {
        agent.ignoreSynchronization = true;
        customer.ignoreSynchronization = true;
        agent.get('http://engager-stage.brandembassy.com/');
        customer.get('https://vps-web-utils.awsbrandembassy.com/livechat-window-gherkin/');
        agent.driver.manage().window().maximize();
        customer.driver.manage().window().maximize();
    });

    it('should be seen offline when agent is offline and viceversa', () => {      
        // check that default status is minimized 
        browser.sleep(2000);
        var elm = customer.element(by.css('[class="be-chat-wrap be-chat-wrap--minimize"]'));
        expect(elm.isPresent()).toBe(true);       
    });
});

Note: I did not use global, since we can just declare the variable outside it function.

Paul Co
  • 447
  • 2
  • 9
  • Thank you, it works, issue was the point you found out. While the declaration of the variables must be put ouside of the describe block on top or test will fail. – SimoneB May 08 '17 at 19:08
  • Glad to help. :) – Paul Co May 08 '17 at 19:32
  • @Paul You don't need to include `global` when you are calling global variables. checkout the 2nd answer in this link - http://stackoverflow.com/questions/31203398/protractor-set-global-variables – Ram Pasala May 08 '17 at 20:01