Protractor's browser.wait function is not functioning properly when conducting tests on a non-AngularJS website

I am currently working on testing a non-angular JS website using Protractor. Even though my test case passes successfully, I am looking to eliminate the sleep statement and replace it with either a wait or Expected condition in my test case.

Here is a snippet of my code:


var co = require('co');
var path = require('path');

describe("TEST ", function () {

    it("test", co.wrap(function* () {
         browser.ignoreSynchronization = true;
        var EC = protractor.ExpectedConditions;
        yield browser.get('URL');
        browser.wait(function () {
            return browser.driver.isElementPresent(by.css(a[href = "#login"]));
        }, 30000);
        var elmOK = browser.driver.findElement(by.css('a[href="#login"]'));
        yield elmOK.click();
        expect(browser.getCurrentUrl()).toContain("login");
        yield browser.switchTo().frame('here-account-sdk').then(function () {
            browser.driver.findElement(by.id('sign-in-email')).sendKeys("<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8dfef8fdfde1e4e8ffd2fde2fff9ece1cdf4ece5e2e2a3eee2e0">[email protected]</a>");
            browser.driver.findElement(by.id('sign-in-password-encrypted')).sendKeys("voting123");
            browser.driver.findElement(by.xpath(' //*[@id="sign-in-form"]/div[2]/div[6]/form/fieldset[3]/button')).click();

        });
        //  browser.sleep(5000);
        var elmOK = browser.driver.findElement(by.xpath('//*[@id="lnav"]/li[3]/a'));
        yield elmOK.click();
        //  browser.sleep(1500);
        browser.driver.findElement(by.xpath('//*[@id="administration"]/div/div[1]/select/option[2]')).click();
        //    browser.sleep(5000);

        browser.driver.findElement(by.xpath('//*[@id="administration"]/div/div[2]/table/tbody/tr[1]/td[10]/span')).click();
        //     browser.sleep(5000);

        browser.driver.findElement(by.xpath('//*[@id="content"]/div/div[2]/div/div/div/div[3]/button[1]')).click();
        //    browser.sleep(5000);
    }));




});

When I attempt to run my test, I encounter the following error message. Can someone provide guidance on how to resolve this issue?

---------------- Spec started:  ----------------                                                                                               
F[13:57:01] E/launcher - Cannot read property '_failures' of undefined                                                                                                             
[13:57:01] E/launcher - TypeError: Cannot read property '_failures' of undefined                                                                                                   
    at null.self.specDone (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\jasmine-reporters\src\junit_reporter.js:274:46)                                                  
    at dispatch (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1966:28)                                  
    at ReportDispatcher.specDone (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1949:11)                 
    at Spec.specResultCallback [as resultCallback] (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:903:18)

    at complete (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:368:12)                                   
    at QueueRunner.clearStack (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:660:9)                      
    at QueueRunner.run (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1881:12)                           
    at C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1898:16                                             
    at C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1842:9                                              
    at C:\Users\jasharma\gitrepo\supplier-portal\node_modules\jasminewd2\index.js:18:5                                                                                             
[13:57:01] E/launcher - Process exited with error code 199                                                                                                                         

Please offer your assistance. Thank you!

Answer №1

Could this be the solution?

 yield browser.switchTo().frame('here-account-sdk').then(function () {
        browser.driver.findElement(by.id('sign-in-email')).sendKeys("<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="91e2e4e1e1fdf8f4e3cee1fee3e5f0fdd1e8f0f9fefebff2fefc">[email protected]</a>");
        browser.driver.findElement(by.id('sign-in-password-encrypted')).sendKeys("voting123");
        browser.driver.findElement(by.xpath(' //*[@id="sign-in-form"]/div[2]/div[6]/form/fieldset[3]/button')).click();

    });

Is the only non-angular-related part in your code? If so, consider adding

browser.switchTo().defaultContent();
before
var elmOK = browser.driver.findElement(by.xpath('//*[@id="lnav"]/li[3]/a'));
.

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

Is there a way to completely define CSS animation using only JavaScript?

I am looking to implement CSS animation on HTML elements that are generated entirely through a JavaScript function. The approach I am taking involves customizing settings and functions for each part of the animation, which is why this method is necessary. ...

Anyone have a sample showcasing the integration of VueJS with the latest webpack 4 configuration?

VueJs templates now come with numerous examples and starting project skeletons. However, most of them still utilize webpack v3. Has anyone experimented with webpack 4? I'd love to see how you integrate version 4 of webpack into a VueJs project. Thank ...

What methods can I use to conceal #! from showing on the browser's address bar?

Imagine you have the below link: www.someurl.com/#!?page=index How would you convert it into one of these options: www.someurl.com/#!/index (using mod_rewrite) www.someurl.com/ajax/index (also using mod_rewrite, but replacing #! with ajax) www.someurl. ...

Guide on creating a toggle effect for a div with querySelector and addEventListener

I utilized the email and password divs provided by Bootstrap. The CSS for the id dropdownlogin includes display: none; in this post, I hope that I have shared adequate information. <script> document.addEventListener('DOMContentLoaded', ...

Having trouble reaching an element within a successful Ajax call

I have encountered an issue where the element is not being recognized when putting an ajax call inside another ajax call. Here is an example of the code: $.ajax({ url: 'controleFatAcoes.php', type: 'post', dataType: 'h ...

Jquery Fails to Execute When Clicking on Radio Button

Whenever a user selects a radio button, I want to display an alert box. I have already written the jQuery code to achieve this. Here is my implementation: <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></ ...

Accessing array values depending on DOM response

Generate a string from selected DOM elements I have an object that contains months and their corresponding index numbers (not dates) monthList = {"jan" : "1", "feb" : "2". etc: etc} The user can input values like jan or jan,feb,march and I need to return ...

What is the simplest way to test an npm module while coding?

Currently, I am in the process of making modifications to @editorjs/nested-list. To streamline my testing process without extensive installations, I have created a simple web page: <html> <head> <script src="https://cdn.jsdelivr.net/npm ...

Incorporating an Edit button with an icon into a react-bootstrap-table2

Is there a way to insert buttons in the Edit column of my table so I can easily edit a row? I believe there should be a method to personalize the column and incorporate icons as shown in the example image. Sample Image of What I want to do: import React ...

Building a local database using the MVC framework concept

Can a locally stored database be developed using MVC framework principles in javascript and html5? Thank you Ravindran ...

Tips for resuming a video playback in HTML5 after pausing it for a brief moment

I am working with a video called introVid, and my goal is for it to pause for 2 seconds when it reaches the 1 second mark before resuming playback. Although I've attempted to achieve this using the code below, the video remains in a paused state after ...

Exploring ways to query a mapped array in React Native

Struggling to search a mapped list in react native? While using a Flatlist would be easier, this task is currently causing me major frustration. If anyone has any insights or solutions, please share them! Here's a snippet of the code: import React ...

Using the KnockOut js script tag does not result in proper application of data binding

Being new to knockout js, I found that the official documentation lacked a complete html file example. This led me to write my own script tags, which initially resulted in unexpected behavior of my html markups. Strangely enough, simply rearranging the pos ...

What is the best way to save the value returned by a foreach loop into an array and then send two responses

After attempting to store the doctor details in an array and display the appointment and doctor Name Value response, I encountered a problem. The Appointment value is successfully achieved, but the doctor Name Value appears empty even though it shows in th ...

What could be causing my post request to function properly in POSTMAN but not in my React application?

Here are my POSTMAN headers along with the settings I used to send my POST. It only started working when I switched the Content-Type to application/json. https://i.stack.imgur.com/Xz2As.png https://i.stack.imgur.com/aJtbD.png This pertains to the server ...

Receive real-time updates on incoming messages in your inbox

I'm seeking advice on implementing live update messages in my code. Here's what I have so far: <script> function fetch_messages(){ var user_id = "1" // example id $.ajax({ url: "do_fetch.php", t ...

The parsererror occurred while executing the jQuery.ajax() function

When attempting to retrieve JSON data from using the following code: (Using jQuery 1.6.2) $.ajax({ type: "GET", url: url, dataType: "jsonp", success: function (result) { alert("SUCCESS!!!"); }, error: function (xhr, ajaxO ...

Splitting Angular modules into separate projects with identical configurations

My Angular project currently consists of approximately 20 different modules. Whenever there is a code change in one module, the entire project needs to be deployed. I am considering breaking down my modules into separate projects for individual deployment. ...

In Vue3, I utilize the Provide and Inject feature to handle data changes without triggering a visual update. Instead, I apply a filter() function to remove an item from an

I am currently testing the usage of the provide and inject methods. I have placed the datas and del-function in the parent component to provide, and in the child component, I am dynamically rendering using v-for='data' in datas. The objective I ...

I'm having trouble accessing my POST data using console.log. Instead of getting the expected data, all I see in the console when I try to GET is "

My code for the POST function is working, but when I try to retrieve and display the POST response from the server, all I get is "null". Can anyone help me figure out how to properly send data from my form to the server and then successfully console log it ...