Skip to content

[Bug]: Playwright v1.51.1: locator.waitFor({ timeout }) unexpectedly waits for visibility #36351

Open
@Sasi4usi

Description

@Sasi4usi

Version

v1.51.1

Steps to reproduce

import { test, expect } from '@playwright/test';

test('waitFor defaults to visible?', async ({ page }) => {
await page.setContent('');
const locator = page.locator('input[type="file"]');

// This should wait only for attachment
await locator.waitFor({ timeout: 5000 });

// This should succeed even though hidden
await locator.setInputFiles('README.md');
});

Expected behavior

It should wait for element to be attached.

Actual behavior

It waits for element to be visible and timed out.

_Error locator.waitFor: Timeout 30000ms exceeded.
Call log:

  • waiting for locator('div[class*='Toolbar_importcontainer'] input[type='file']') to be visible
    63 × locator resolved to hidden_

Additional context

Input element with type as file is hidden. Using await locator.waitFor({ timeout: 5000 }); throws the following error:

_Error locator.waitFor: Timeout 30000ms exceeded.
Call log:

  • waiting for locator('div[class*='Toolbar_importcontainer'] input[type='file']') to be visible
    63 × locator resolved to hidden_

Environment

System:
  OS: Windows 10 
  Node: v22.13.0 
  npm: 10.9.2 
  @playwright/test: 1.51.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions