5

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',

       };
  • 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() – keasav rao Dec 20 '17 at 7:16
  • Can you increase the parameter allScriptsTimeout: 500000 to 600000 check it?(NB: since it is in milliseconds) – Bhavani Dec 21 '17 at 11:23
1

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.
  },
}
0

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, privacy policy and cookie policy

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