6

Current Behavior:

If any TestCase is Failed, Protractor not continuing with the next Testcase and holding to the same failed Testcase . Waits for long time and throws A Jasmine spec timed out. Resetting the WebDriver Control Flow.

EXPECTED BEHAVIOR:

On failure on any Testcase, Protractor should continue with next TestCase.

Can anyone help with Sample script for it.

CONFIG.js :

 var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
 var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
 var fs = require('fs');
 require('protractor/built/logger').Logger.logLevel = 1;
 exports.config = {

    //seleniumServerJar: "node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.3.1.jar",
    framework: 'jasmine2',
    directConnect: true,
    capabilities: {

        'browserName': 'chrome',
        'chromeOptions': {
            'args': ['incognito', '--start-maximized'],  // this line is for maximize the window and incognito view

            prefs: {
                'profile:managed_default_content_settings.notifications': 1,
                args: ['--no-sandbox', '--test-type=browser'],
                'download': {
                    'prompt_for_download': false,
                    'default_directory': 'C:/Users/AAA/AppData/Roaming/npm/node_modules/protractor/Workspace/Reports/Download/'
                },
            },

        },
    },
    allScriptsTimeout: 500000,
    ignoreUncaughtExceptions: true,
    jasmineNodeOpts: {
        isVerbose: true,
        showColors: true,
        includeStackTrace: true,
        displaySpecDuration: true,
        defaultTimeoutInterval: 360000,
        print: function () {
        }
    },

    onPrepare: function(){
        browser.manage().window().maximize();          // set browser size...
        rmDir('C:/Users/AAA/AppData/Roaming/npm/node_modules/protractor/Workspace/Reports/Download');
        require('./Data/waitReady.js');


        // better jasmine 2 reports...
        global.isAngularSite = function(flag){
            browser.driver.ignoreSynchronization = !flag;
        };
       // Remove files in Specified Directory

        jasmine.getEnv().addReporter(new SpecReporter({
            spec: {
                displayStacktrace: true,
                displayFailuresSummary: true
            }

        }));
        var jasmineReporters = require('jasmine-reporters');
        jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
            consolidateAll: true,
            savePath: './Reports/JunitXMLprotractor-result/',
            filePrefix: 'xmloutput'
        }));

        jasmine.getEnv().addReporter(
            new Jasmine2HtmlReporter({
                savePath: './Reports/Screenshots/',
                takeScreenshots: true,
                takeScreenshotsOnlyOnFailures: true,
                consolidateAll: true,
                showPassed: true,
                // filePrefix: sessionId + 'AutomationReport',
                filePrefix: 'AutomationReport',
                cleanDestination: true,
            })
        );


    },

       //  specs : './AAA/ListPage_EM_Acc_Spec.js',

       };
3
  • Yes alecxe. it holds to same it() and i get error as "A Jasmine spec timed out. Resetting the WebDriver Control Flow." for next it()
    – Bustaq
    Dec 20, 2017 at 7:16
  • Can you increase the parameter allScriptsTimeout: 500000 to 600000 check it?(NB: since it is in milliseconds)
    – Bhavani
    Dec 21, 2017 at 11:23
  • yes, i am using failFast so if we are running a suite which has 30 spec files and each spec file it having on average 5 IT blocks . So now when we run locally or in jenkins if one of the IT blocks fails then the rest of the specs/IT blocks doesnot execute . I wanted fail fast to only mark the particular IT block or Spec to fail and move on to next spec and execute those as there is not dependency between specs . How can we achieve that in protractor (jasmine framework) ????? Please could someone help me here Apr 22, 2021 at 5:38

2 Answers 2

2

You need to use "fail-fast" Plugins like Protractor-Fail-Fast.

This allows Protractor tests to "fail-fast", exiting on the first failure instead of running all tests no matter what.

Installation(npm):

npm install protractor-fail-fast

Usage:

import failFast from 'protractor-fail-fast';
 
exports.config = {
  plugins: [
    failFast.init(),
  ],
  
  // Optional
  afterLaunch: function() {
    failFast.clean(); // Removes the fail file once all test runners have completed.
  },
}
2
  • import failFast is throwing syntax error
    – PDHide
    Dec 19, 2019 at 16:02
  • Then use other open libraries supporting this feature. The point was at the time of writing the post that it can be achieved using these kind of plug-ins. Apr 23, 2021 at 8:14
1

Looking at the config file, I don't see any reason why your script should stop/timeout on any failure. Can you please check if there is any setup or tear down script you are running in npm. if so, try making it part of protractor in beforeLaunch and afterLaunch.

if for some reason you can't make it part of the protractor, try changing the protractor exitCode to 0. You can either do that in afterLaunch or write a script around your protractor run script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.