Navigating back to an Angular page from a non-Angular page using Protractor

Is there a specific method to return to an angular page? Below is the input and button code from an HTML (non-angular) page:

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

The script in todo-spec.js looks like this;

 element(by.css('.value')).sendKeys('12345');
 element(by.buttonText('Submit')).click();

I have included

browser.driver.ignoreSynchronization = true;
at the end of the previous angular page to disable synchronization. However, it seems that this page interacts with a payment gateway service before redirecting to subsequent angular pages. Despite my attempts to disable synchronization, I am encountering errors.

It should be noted that I am receiving two distinct errors each time I run the same SCRIPT EXACTLY back-to-back. One error message reads;

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

and the other one states;

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)

Your assistance in resolving these issues would be greatly appreciated...

Answer №1

Resolved. I found that the solution to my issue had actually been suggested by others previously, but I had misunderstood it due to its similarity to other problems on Stack Overflow.

To ensure proper loading and settling on a non-angular page, I had to utilize browser.driver.sleep(5000) to prevent Protractor from rushing through it.

In order to address occasional jasmine timeouts that made me question if I was in the wrong all along, I explicitly set the timeout in the beforeEach function at the beginning. Refer to this example;

The usage of beforeEach can be seen here (Configuring defaultTimeoutInterval in config.js did not resolve the issue for me.)

  describe('angularjs homepage todo list', function() {

    beforeEach(function (done) {
       jasmine.DEFAULT_TIMEOUT_INTERVAL = 80000;
       setTimeout(function () {
           done();
       }, 500);
    });

   it ('should be bla bla bla', function(){

Another portion within the describe-it function (angular>>non-angular>>angular)

    browser.ignoreSynchronization = true; 
    this_page.clickBtn(); 

    
    //*NON-ANGULAR PAGE* loaded (payment gateway)
    browser.driver.sleep(5000);

    element(by.css('.value')).sendKeys('12345');                     
    element(by.buttonText('Submit')).click(); 

If anyone has a different perspective on this, feel free to correct me. It took me a week of frustration to understand this aspect. - Newly minted 'protractorer' ;)

Also IMPORTANT TIP: when dealing with angular check boxes and radio buttons, make sure to use;

    var elm = element(by.id('drop-off'));
    browser.executeScript("arguments[0].click();", elm.getWebElement());

instead of just

element(by.id('drop-off')).click(); 

I discovered that materialize hides the actual element in the check-box / radio button design, leading to undetected errors by protractor/webdriver. This awareness is crucial for effective communication with the backend. A small detail, yet significant once addressed. After resolving this, my protractor tests ran smoothly.

Another key learning was the importance of paying attention to webdriver errors, which provided more explicit guidance compared to protractor errors.

Answer №2

Upon clicking, I will patiently await being redirected to the designated page (ensuring a specific segment of URL is present in the current URL), re-enable synchronization, and trigger waitForAngular():

browser.driver.wait(function() {
  return browser.driver.getCurrentUrl().then(function(url) {
    return /section/.test(url);  // NOTE: Substitute "section" with an appropriate part of URL for your scenario
  });
}).then(function () {
    browser.ignoreSynchronization = true;     
    browser.waitForAngular();
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Adding Currency Symbol to Tooltip Data in Material-UI Sparklinechart

Below is a SparklineChart example using MUI library: import * as React from 'react'; import Stack from '@mui/material/Stack'; import Box from '@mui/material/Box'; import { SparkLineChart } from '@mui/x-charts/SparkLineCha ...

Use jQuery to extract data from the URL instead of relying on PHP

http://h3gsat.altervista.org/DettagliCompleto.php?id=4567 I attempted to extract the id parameter without success. I am attempting to accomplish this using JavaScript (jQuery) instead of PHP, but I am unsure of how to proceed. ...

Analyze React.js source code for errors, instead of focusing solely on the DOM manipulation aspect

Can breakpoints be set in React.js code and debugged in the actual script rather than just in compiled javascript? For example: var HelloMessage = React.createClass({ render: function() { return <div>Hello {this.props.name}</div>; // ...

Encountered an issue accessing property 'Component' which is undefined during the webpack build of a React component plugin

I have developed a wrapper for my leaflet plugin called leaflet-arrowheads using react-leaflet. This component is designed to be installed as an npm package, imported, and used easily. The structure of the component is quite simple: import React from &apo ...

Problem with Onsen UI navigation: It is not possible to provide a "ons-page" element to "ons-navigator" when attempting to navigate back to the initial page

Hi, I am having trouble with navigation using Onsen UI. Here is the structure of my app: start.html: This is the first page that appears and it contains a navigator. Clicking on the start button will open page1.html page1.html: Performs an action that op ...

Removing the previously selected file from an input type file in Angular JS

I am implementing an upload control using AngularJS with the input type="file" feature. Whenever I click on browse, the previously selected file is retained by default, but I want to prevent this behavior. Is it possible to achieve this by creating a custo ...

What are some ways to avoid an image looking faded when adding it to the scene background in Three.js?

I've been experimenting with loading images onto the scene background using the TextureLoader() class to prevent them from appearing greyed out. Following a tutorial on three.js https://www.youtube.com/watch?v=xJAfLdUgdc4&list=PLjcjAqAnHd1EIxV4FS ...

What are the downsides of using PHP redirects instead of JavaScript redirects, given that most large websites opt for the latter?

After closely examining the source codes of redirect pages on several major websites that redirect to their sponsors, I found an interesting pattern. Out of the five websites analyzed, four were using different Javascript redirects: <script type="text ...

Is it possible to increase Google+ shares without needing an API key for every single page?

Looking to retrieve the number of Google+ shares for each URL on a search results page using Ajax. Facebook and Twitter share counts have been successfully implemented: $.getJSON('http://urls.api.twitter.com/1/urls/count.json?url=' + url + & ...

Utilize the Vue-Chartjs plugin registration for a specific chart component only

I am currently working with a chart component in Vue 3 using the composition API. My goal is to incorporate the datalabels plugin into this specific chart only. Upon attempting to register the plugin outside of the chart's data or options, I noticed ...

Troubleshooting jQuery masonry problem related to initial display and height settings

Within a div, there is a masonry container with the inline style property display:none. With several divs on the page, clicking their respective buttons during load causes them to switch like a slideshow. This disrupts masonry's ability to calculate t ...

What are the advantages of using Angular.js with the built-in router, and how does incorporating node.js & express.js further enhance the

I am currently learning Angular.js and I have noticed that both Angular and Node.js with Express.js have routers. Can you please explain the differences between the two? This information will be very valuable for my understanding of MEAN stack developmen ...

What is the reason behind ASP MVC model binder's preference for JSON in POST requests?

Is there a way to bind data to a model when sending a 'GET' request with JSON.stringify() using AJAX? Currently, the model value is always null when using 'GET', but it works fine with 'POST'. Are there any solutions for this ...

Creating PDF files from elements using Puppeteer JS

In my quest to master the usage of Puppeteer within a Vue.js application, I am facing a challenge. I am able to create a PDF based on the entire page successfully, but I am struggling to generate a PDF for a specific element on the page. Is there a method ...

Using ng serve to upload multipart files in Angular 2

I am currently working on the front end of a file uploading service and have encountered a strange issue. When I restart the server using ng serve, it throws an error related to generated components within the app component. The error message can be seen h ...

Send parameters to the $http service from a directive

I utilize this specific service model to retrieve comments from the database: .service('getComArt', function($http) { delete $http.defaults.headers.common['X-Requested-With']; this.getData = function(callbackFunc) { $ht ...

The functionality of two-way data binding seems to be malfunctioning within the directive

This is my first attempt at creating a directive in AngularJS and I am still learning the ropes. I'm currently experimenting with integrating Bootstrap Year Calendar with AngularJS. The Bootstrap Year Calendar is a jQuery plug-in designed to display ...

This function appears to have an excessive number of statements, totaling 41 in total

Currently, I am using this controller: .controller('ctrl', function($scope, $rootScope, $timeout, $alert, $location, $tooltip, $popover, BetSlipFactory, AccordionsFactory, AuthFac ...

Looking to display an alert message upon scrolling down a specific division element in HTML

In the midst of the body tag, I have a div element. <div id="place"> </div> I'm trying to achieve a scenario where upon scrolling down and encountering the div with the ID "place", an alert is displayed. My current approach involves che ...

Include jQuery, jQuery UI, and plugins seamlessly to avoid any version conflicts

My goal is to inject my custom code into a webpage using a bookmarklet. This code requires jQuery, jQuery UI, and additional plugins to be included on the page. I'm aware of the noConflict function, but I have concerns about potential conflicts if ot ...