Skip to content

feat: allow passing options to click() and press()#233

Open
DanielGSoftware wants to merge 1 commit into
pestphp:4.xfrom
DanielGSoftware:feat/click-press-options
Open

feat: allow passing options to click() and press()#233
DanielGSoftware wants to merge 1 commit into
pestphp:4.xfrom
DanielGSoftware:feat/click-press-options

Conversation

@DanielGSoftware

Copy link
Copy Markdown

Description

click() and press() currently call the underlying Playwright locator with no options, so there's no way to pass locator options such as noWaitAfter, timeout, position, or button.

This adds an optional ?array $options = null parameter to both, forwarded straight through to the locator's click():

$page->press('Submit', ['noWaitAfter' => true])
    ->assertPathIs('/next-page');

Motivation

The main driver is noWaitAfter for actions that trigger a navigation. Today a click()/press() that navigates can hang until the timeout on pages whose load doesn't settle quickly (e.g. Livewire/SPA pages that fire a request after the load event) — see pestphp/pest#1511. noWaitAfter lets the action dispatch without blocking on the navigation to settle; a following assertPathIs/assertSee (still retried) then confirms the result. This is a narrow, opt-in option rather than a change to the global retry behavior.

Tests

Added forwarding tests for both click and press — they pass ['button' => 'right'] and assert a contextmenu handler fired, which a plain click would not trigger, proving the option reaches the locator. Existing click/press tests are unchanged.

  • composer lint (pint + rector), phpstan, and 100% type-coverage pass
  • browser tests pass

Forwards an optional array of Playwright locator options through click()
and press() to the underlying locator. This enables options such as
noWaitAfter for actions that trigger a navigation, which otherwise hang
(see pestphp/pest#1511).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant