0

I am running into this issue where I execute my protractor test only to find out that it has failed. Now the issue is not with the actual functionality failing but with the Default Timeout Interval apparently. The Code runs fine, performs all the operation on the Webpage and just when you expect a green dot it errors out.

Before anyone marks it duplicate, I would just like to tell that I have tried the below approaches going through the answers of other similar question.

  1. Included argument in the "it" block and called the argument after the test.
  2. Changed the default_timeout_interval in conf.js file to 30s.
  3. Tried using Async/await in the last function to wait for the promise to get resolved.

I would not only like to find a answer to this one but also if someone can give me an explanation on what exactly Protractor wants to convey here. To me as a novice in JavaScript and Protractor this looks like a very vague message.

Below is my spec file :

describe("Validating Booking for JetBlue WebApplication", function(){


    var firstPage = require("../PageLogic/jetBlueHomePage.js");
    it("Validating One Way Booking", function(pleaserun){

        firstPage.OneWayTrip();
        firstPage.EnterFromCity("California");
        firstPage.EnterToCity("New York");
        firstPage.SelectDepartureDate();
        firstPage.searchFlights();
        pleaserun();
    });

});

Below is my Page file:

var homePage = function(){

    this.OneWayTrip = function(){
        element(by.xpath("//label[text()=' One-way ']/parent::jb-radio/div")).click();
    }

    this.EnterFromCity = function(FromCityName){
        element(by.xpath("//input[@placeholder='Where from?']")).clear();
        element(by.xpath("//input[@placeholder='Where from?']")).sendKeys(FromCityName);
        browser.sleep(3000);
        element(by.xpath("//ul[@id='listbox']/li[1]")).click();
    }

    this.EnterToCity = function(ToCityName){
        element(by.xpath("//input[@placeholder='Where to?']")).clear();
        element(by.xpath("//input[@placeholder='Where to?']")).sendKeys(ToCityName);
        browser.sleep(3000);
        element(by.xpath("//ul[@id='listbox']/li[1]")).click();
        browser.sleep(3000);
    }

    this.SelectDepartureDate = function(){
        element(by.xpath("//input[@placeholder='Select Date']")).click();
        browser.sleep(3000);
        element(by.xpath("//span[text()=' 24 ']")).click();

    }

    this.NumberOfPassengers = function(){
        element(by.xpath("//button[@pax='traveler-selector']")).click();

    }

    this.searchFlights = async function(){
        await element(by.buttonText('Search flights')).click();    
    }

};

module.exports = new homePage();

Below is the Conf.js file :

exports.config = {
    directConnect: true,
    specs:["TestSpecs/jetBlueBookingTest.js"],
    onPrepare: function(){
        browser.get("https://www.jetblue.com/");
        browser.manage().window().maximize();
    },
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000,
        isVerbose: true,
        includeStackTrace: true,
    }
};

Seeking help from all the protractor pros out there to help me get this solution and hopefully make me understand the concept.

Kovid Mehta
  • 531
  • 2
  • 8
  • 28
  • What is `pleaserun()`. Update the code for the same – Madhan Raj Oct 14 '19 at 06:08
  • The default way protractor handles promises is called the control flow, which you are currently using. You should not use `async/await` while the control flow is enabled as this can lead to unexpected behavior. Can you confirm you see the same behavior removing async/await while the 30 seconds default timeout period is still being used – DublinDev Oct 14 '19 at 12:08
  • Hi Madhan, took the reference of it from this answer : https://stackoverflow.com/questions/22604644/jasmine-async-callback-was-not-invoked-within-timeout-specified-by-jasmine-defa – Kovid Mehta Oct 14 '19 at 14:40
  • Hi DublinDev, Hey thanks for the note. I tried with this approach and it worked today. But I was trying to do the same other day and It was not working, that's why I added await/async as well. It would be great if you can help me understand which one to use when. – Kovid Mehta Oct 14 '19 at 14:55

1 Answers1

0

the message means that an async script was run in the browser, and it hasn't returned a result within the expected time limit. it would be useful if you could share the full error stack, the root cause is probably mentioned deeper down in it