Running only failed tests in Protractor can be achieved by implementing a custom script that

I've encountered a problem in my JavaScript file where some of the test cases fail intermittently, and I want to rerun only those that have failed. Is there any feature or solution available that can help with this issue? It's quite frustrating and time-consuming to run everything again. Below is an example of how my spec looks like.

describe('Test -> Users table with admin privileges', function () {
var EC = protractor.ExpectedConditions;
var welcomePage = new WelcomePage();
var usersPage = new UsersPage();

beforeEach(function () {
    LogIn.asAdmin1();
    clickWithWait(welcomePage.usersButton);
    browser.wait(hasNonZeroCount(usersPage.allRows), WAIT_TIMEOUT, 'users list did not appear');
});

afterEach(function () {
    welcomePage.logout();
});

it('verifies counter on active tab', function () {
    browser.wait(EC.elementToBeClickable(usersPage.allRows.first()), WAIT_TIMEOUT, 'firstRow was not visible ');
    usersPage.allRows.count().then(function (count) {
        expect(usersPage.activeTab.getText()).toContain('Active' + ' (' + count + ')');
    });
});

it('verifies counter on archived tab', function () {
    browser.wait(EC.elementToBeClickable(usersPage.allRows.first()), WAIT_TIMEOUT, 'firstRow was not visible ');
    // Initial condition for case of none archived user have to be added here (it will remove if statement).
    clickWithWait(usersPage.archivedTab);
    usersPage.allRows.count().then(function (count) {
        if (count > 0) {
            expect(usersPage.archivedTab.getText()).toContain('Archived' + ' (' + count + ')');
        } else {
            console.log("Test Ignored due to none records")
        }
    });
});

Answer №1

NickTomlin came up with a rather mature solution involving protractor-flake

Described as "a tool that helps in automatically re-running failed Protractor specs for a set number of attempts", protractor-flake can be implemented by following these two links:

  1. https://www.npmjs.com/package/protractor-flake
  2. https://github.com/NickTomlin/protractor-flake/blob/master/docs/cucumber.md

Don't forget to read the Caveat section on the NPM page:

*Caveats

The compatibility of this tool with Protractor and Mocha is untested, although it should work similarly. If you encounter any issues, feel free to raise an issue or submit a PR.

If you have a custom reporter that doesn't log stack traces for failed tests, the tests may not rerun correctly (all tests will run each time). For instance, ensure your jasmine-spec-reporter for Jasmine 2.0 is set to displayStacktrace: 'specs' or displayStacktrace: 'all'.*

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

save function ajax failure

I have created a function that adds a row after confirmation. The issue is that after submitting, the tables do not reload and show an error alert. In reality, the data is successfully saved but I need to refresh the page for the table to reload. Below is ...

What distinctions can be made between Controlled and Uncontrolled Components when using react-hooks-form?

Trying out the React Hooks form, I came across some interesting concepts like controlled and uncontrolled forms. Controlled Form <form onSubmit={handleSubmit(onSubmit)}> <input name="firstName" ref={register({ required: true })} /> ...

Implement authentication verification on all child endpoints within an express router

I have an express router set up and I want only authorized users to access its routes. I am currently using passport middleware. Instead of adding a check for req.user in every endpoint, is there a more efficient way to handle this? router.get("/", asyn ...

Ember Gain a comprehensive understanding of the flow of execution between route and controller

Below is a snippet of my "box" route/controller: export default Ember.Controller.extend({ initialized: false, type: 'P', status: 'done', layouts: null, toggleFltr: null, gridVals: Ember.computed.alias('mode ...

Retrieving the DOM of an HTML document in Java

In my current project, I am using headless Chrome as a WebDriver for Selenium tests written in Java. I have noticed potential changes to the DOM when using the headless version of Chrome. Is there a method available to access a copy of the HTML DOM durin ...

The font size appears significantly smaller than expected when using wkhtmltoimage to render

I am trying to convert text into an image, with a static layout and size while adjusting the font size based on the amount of text. I prefer using wkhtmltoimage 0.12.5 as it offers various CSS styling options. Currently, I am working on a Mac. Below is a ...

"Stellar.js fails to function properly when applied to elements loaded dynamically through AJAX requests

I recently implemented the amazing Stellar.js for parallax effects in a project of mine. However, I've encountered an issue: Stellar.js does not recognize when I update content via AJAX (specifically loading new div elements from an HTML file and rep ...

Angular AutoComplete feature does not accurately filter the list items

I need to implement an auto-complete feature for the county field due to a large number of items in the list causing inconvenience to users who have to scroll extensively. Currently, there are two issues with the code. The first problem is that although t ...

The subsequent menu selection will be based on the chosen menu value

I am attempting to accomplish the following: https://i.sstatic.net/JffUWC02.png Essentially, I need a select options menu with labels where selecting an option will display a corresponding value. These values should then become labels for a second selec ...

"ReactJS error: Unable to upload file due to a 400

Every time I attempt to upload a file, I encounter this error: "Uncaught (in promise) Error: Request failed with status code 404". I'm puzzled as to why this is happening. Here's the section of my code that seems to be causing the issue. ...

Ways to Implement Horizontal Scrolling in Dojo FilteringSelect Component

The select field on my form contains option values that are over 250 characters long, making it difficult for users to read them within the select box. Is there a solution to make the select field scroll horizontally or wrap the lengthy text? ...

I'm receiving identical results from findOne even when using different IDs

I am currently working on creating a new array of products based on a list of different Ids. However, I have encountered an issue where the same product is being returned for all Ids when using the findOne() method. let wishpro = ['632a5e5rtybdaaf ...

Guide on deactivating the div in angular using ngClass based on a boolean value

displayData = [ { status: 'CLOSED', ack: false }, { status: 'ESCALATED', ack: false }, { status: 'ACK', ack: false }, { status: 'ACK', ack: true }, { status: 'NEW', ack ...

My project is not compatible with the headless mode of Selenium

I'm currently tackling a web scraping project focusing on a popular ecommerce platform. I want to keep the browser hidden during this process, and usually, using the "--headless" option would do the trick. However, the specific page I'm trying to ...

Is it possible for me to perform cross-site scripting using JavaScript within my personal browser, specifically Firefox?

While watching a Video Tutorial on a certain website, I noticed that the videos were hosted on platform.thinkific.com and displayed in a light theme. However, I prefer Dark Theme, so I decided to invert the color of the video using the filter: invert(90%) ...

What is the significance of the 'this' context type void not being assignable to type rule?

Currently, I am conducting tests using Typescript to explore the feasibility of a project I have in mind. In one of my functions, I need to specify the type of 'this' as a class. While it technically works, I continue to encounter an error messag ...

Selenium - Reloading a slow-loading page

One of the challenges I'm facing is with a for loop that opens various webpages from a list, takes a screenshot, and proceeds to the next webpage. However, sometimes the browser struggles to load a page, requiring a manual refresh to get the script ba ...

Having trouble accessing a parsed JSON value in Node.js, encountering 1 error

Currently, I am working on creating a simple news web application as a way to practice utilizing APIs. The particular API that I have chosen for this project is . If you take a look at this JSON object that I am attempting to console.log, you will see the ...

"Encountering an unidentified custom element in Vue 2 while exploring Vue libraries

In my Vue project, I have integrated libraries like FusionCharts and VueProgressBar. However, I encountered an error in my console: Unknown custom element: <vue-progress-bar> - did you register the component correctly? For recursive components, make ...

Transitioning from using FireFoxDriver to ChromeDriver results in encountering issues with loading certain elements (Selenium)

In my current selenium project, I have been using FireFoxDriver. However, upon trying ChromeDriver (which is significantly faster), I have encountered numerous test failures with the error messages "element not visible" or "Element is not currently interac ...