colinDev256 colinDev256 - 4 months ago 238x
AngularJS Question

How to navigate from a non-Angular page back to another Angular page with protractor

What exactly should be done to redirect back to an angular page? This is my input & button from html (non-angular page)

<input class="value" type="password" 3dsinput="password" name="password">
<input type="submit" value="Submit" name="submit" alt="Submit" border="0">

located in todo-spec.js like this;


browser.driver.ignoreSynchronization = true;
called last on the previous angular page to turn off synchronization. Keep in mind this little page communicates with a payment gateway service before it redirects the user to oncoming angular pages. I've tried to switch off synchronization but to no relief.

Also to note: I seem to be getting two different errors whenever I run the same EXACT SCRIPT minute after minute. My guess is it's something to do with timeout. One is;

Failed: Cannot assign to read only property 'stack' of Error while waiting for Protractor to sync with the page: "window.angular is 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 for details"

and the other;

Failed: javascript error: document unloaded while waiting for result
(Session info: chrome=51.0.2704.84)
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 10.0 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.40 seconds
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42'
System info: host: 'xxxxxxxx', ip: 'xxxxx', 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_92'
Driver info:
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={chromedriverVersion=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4), userDataDir=C:\Users\Colin\AppData\Local\Temp\scoped_dir6892_17447}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=51.0.2704.84, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: fde99ca463aacd06f923cae8895b06a5

Your help shall be highly appreciated...


Solved. Two things - Synchronization & timeouts - very important! Synchronization was not switched off after loading the non-angular page. Synchronization has to be switched on and off on every angular page to keep it end2end testing (to avoid backend). Switch it off before clicking to redirect to new page and switch it back on when the new page comes through and repeat procedure for every angular page. Secondly I had to use browser.driver.sleep(6000) to ensure non-angular page loads in properly and that protractor does not quickly run over it. To manage jasmine timeouts (which was a MAJOR issue - making me feel like I was the wrong one all along), I explicitly programmed the timeout in the beforeEach function. Take a look;

The beforeEach (Setting defaultTimeoutInterval in config.js did not work for me.)

    beforeEach(function (done) {
       jasmine.DEFAULT_TIMEOUT_INTERVAL = 80000;
       setTimeout(function () {
           // console.log('inside timeout');
       }, 500);

Other section of in the describe-it function

    browser.ignoreSynchronization = true; // Turn sync off before submit
    payment_details.clickBtn(); //Redirect to *NON-ANGULAR PAGE*

    //*NON-ANGULAR PAGE* loaded (payment gateway)
    browser.ignoreSynchronization = true; //Since non-angular page has been returned, re-establish explicit call to keep synchronization off.

    element(by.buttonText('Submit')).click(); // no need to switch off synchronization before click() here since this is a non-angualar page.

    //Redirect to Confirmation page (angular)
    browser.get('https://xxxxx/confirmation/1'); // dummy ID @ end of url.

Again I stand to be corrected if anyone feels different about this. Took me a week of up and down frustration to figure this bit out. - New 'protractorer' ;)

One more thing that greatly helped me was paying attention to webdriver errors (which I was not doing before). They were more explicit than the protractor ones.