What is the best way to adjust the timeout for a specific action or test?

My PlaywrightTestConfig file has a global timeout setting of 2 minutes. However, in a specific test case, I need to wait for 10 minutes for a file validation process to complete.

const config: PlaywrightTestConfig = {
  // Timeout for each Playwright action in milliseconds. Defaults to 0 (no timeout)
  timeout: 120000
  ...
}

I have attempted various methods to override the global timeout:

  1. click({ timeout: 600000 });
  2. test.slow();
  3. test.setTimeout(600000);
  4. page.setDefaultTimeout(600000);
  5. page.setDefaultNavigationTimeout(600000);

Unfortunately, regardless of these efforts, the test still times out after 2 minutes instead of the intended 10-minute override (600000).

Increasing the global timeout might seem like a solution, but it would slow down the entire test suite, which is not ideal.

Is there a way to set a step-specific timeout that exceeds the global timeout?

Answer №1

Implement a custom timeout feature for specific actions:

Define the specific action within the Page Object :

 async performCustomAction() {
  //execute certain test steps
   await page.click(someElement)
   await page.waitForSelector(elementToAppear,{timeout:300000})
  //additional steps
}

Using the custom timeout in the test case:

test('Performing customAction', async () => {
    await page.performCustomAction()  
  },500000)

For more information, visit: https://example.com/custom-timeout-guide

Answer №2

It seems like your test suite includes a variety of tests with different durations. One possible solution to organize them based on duration is by dividing them into separate projects. This way, you can set specific timeout values for each project instead of using a single global timeout value that may not be suitable for all scenarios.

{
  "use": [
    {
      "browserName": "chromium",
      "timeout": 120000
    },
    {
      "browserName": "chromium",
      "timeout": 600000,
      "testMatch": '/long-tasks/**/*.spec.js',
    }
  ]
}

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

Executing the routing component prior to any other tasks

Having an issue where the ProductsService is fetching data from the server and storing it in an Array. The ProductsComponent serves as the parent component, while the ProductsListComponent and ProductListItemsComponent are its children components. The flow ...

Building an Angular CLI application with Typescript that handles multiple HTTP calls using polling through a timer

I am working with a Django backend and I need to check the status of multiple Celery Tasks () every 3 seconds. For instance, let's say I have 4 task IDs: 3099023 3493494 4309349 5498458 My goal is to make an http.get<...>(backend) call every ...

I am facing difficulty in deploying my Next.js app with Firestore

Having trouble deploying my application using npm run build, Vercel, or another service. It works fine locally without showing any errors. I am using Firebase, Next.js, and TypeScript. The issue seems to be related to getStaticProps. When requesting data, ...

The Typescript compiler is failing to catch a missing import for lodash when using webpack

Currently in the process of setting up webpack with Typescript for my project using resources from the official tutorial. Below is an overview of my folder structure and key files: ├── dist │ ├── bundle.js │ └── index.html ├─ ...

Tips for managing UI Automation issues such as dealing with messages like "To complete the logout process, you must close the browser" while utilizing selenium in conjunction with the pytest framework

Insight: Currently, I am conducting my data-driven UI automation tests using Selenium with the Pytest framework. In this setup, there are a total of 60 test cases to be executed. The scope is set at the session level, where logging into the application oc ...

Is there a way to insert a secured page right before accessing the dashboard?

I am trying to create a locked page that will display a message when users access the web app from a mobile device and load a mobile layout page displaying a message like mobile is not supported. I was considering using document.addEventListener('DOMC ...

Utilizing various filters and sorting options on API response within Angular 8

Upon receiving the following API response: [ { "imgPaths":[ "gallery/products/55ccb60cddb4d9bded02accb26827ce4" ], "_id":"5f3e961d65c6d591ba04f3d3", "productName":" ...

Error message in Node.js: Configuration file not found for eslint

I've been working on setting up TypeScript and ESLint for my new Node.js Express app, but I keep encountering the Error: Could not find config file. Here's a glimpse of my package.json: { //####### //####### "scripts": {}, "dependencies" ...

Using TypeScript in React, how can I implement automation to increment a number column in a datatable?

My goal is to achieve a simple task: displaying the row numbers on a column of a Primereact DataTable component. The issue is that the only apparent way to do this involves adding a data field with indexes, which can get disorganized when sorting is appli ...

What is the best way to transform JavaScript into TypeScript?

I've been researching TypeScript extensively, but I'm still unsure about what type I should set for elements X and Y. Can someone help me understand how I can convert this code to TS? Thank you in advance for your assistance. const x = document.g ...

How to correctly type the return value of an asynchronous thunk in Redux Toolkit using TypeScript

I am currently working with an async thunk that looks like this: export const updateIndexingConfig = createAsyncThunk( "settings/updateIndexingConfig", (config: UpdateIndexingConfigurationRequest) => { return sdkClient.updateIndexingCo ...

Exploring a TypeScript Object to uncover a desired value

Searching for the correct key in the object that corresponds to the value "1". The function currently outputs undefined, which is the intended behavior. input : deliveryIds: [5,4,5,3,3] output: 4 This code snippet aims to find the missing quad by iterat ...

What is the best approach to organize data from an observable based on a nested key?

I'm currently developing a new application and struggling with grouping data. The data is being pulled from an observable, and I need to group objects by their status and push them into an array. I attempted to use the groupBy() method, but unfortunat ...

"Linking a Next.js application with Azure's Application Insights for advanced insights

Trying to include my Next.js (TypeScript) app logs in Azure Application Insights has been a bit challenging. The documentation provided poor guidance, so I decided to follow this solution: https://medium.com/@nirbhayluthra/integrating-azure-application-ins ...

Is it possible to replicate Microsoft Authenticator using Java-Selenium?

Currently, I am exploring Java-Selenium testing for our application which recently integrated Microsoft Authenticator into the login process. However, logging in with Selenium has become challenging as users now need to approve from their mobile devices b ...

The superclass defines the type of the subclass

There is an abstract typescript class like this: abstract class Abstract { constructor (public parent?: Abstract) { } } Then, two subclasses are defined as follows: class Sub1 extends Abstract { } class Sub2 extends Abstract { } The issue aris ...

What kind of impact does the question mark at the conclusion of a function title make?

I came across the following TypeScript code snippet: class Foo { start?(): void {} } What caught my attention was the ? at the end of start. It appears to be making the function optional (but how can a function be optional and when would you need tha ...

invoke a method from an existing component within a different component

section 1 import { Component } from '@angular/core'; @Component({ selector: 'app-section1', template: ` <button (click)="submit()"></button> ` }) export class Section { constructor() { } so ...

What is the best way to access the first child element within props.children?

As a newcomer to React.js and Typescript, I am currently facing a challenge in extracting the first element from props.children. I have grasped that the parent component receives props.children as either React.element or an array of React.element[]. My g ...

What causes the form to consistently show as invalid once it has been submitted?

register.html : <form [formGroup]="signupForm" (submit)="onSubmit()" class="form-detail"> <h2>Registration Form</h2> <div class="form-row-total"> <div class="form-row"> <in ...