From 0176e9d35001cc5ae9c34336075ed4643fb24330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Andr=C3=A9?= Date: Sun, 14 Sep 2025 22:50:24 +0200 Subject: [PATCH] Handle blur command --- bin/lib/handlers.js | 1 + tests/Integration/Locator/LocatorTest.php | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/bin/lib/handlers.js b/bin/lib/handlers.js index c361d3c..7adef2c 100644 --- a/bin/lib/handlers.js +++ b/bin/lib/handlers.js @@ -235,6 +235,7 @@ class LocatorHandler extends BaseHandler { click: () => locator.click(command.options), dblclick: () => locator.dblclick(command.options), hover: () => locator.hover(command.options), + blur: () => locator.blur(), focus: () => locator.focus(command.options), fill: () => locator.fill(command.value, command.options), type: () => locator.type(command.text, command.options), diff --git a/tests/Integration/Locator/LocatorTest.php b/tests/Integration/Locator/LocatorTest.php index 543382f..53d2a3f 100644 --- a/tests/Integration/Locator/LocatorTest.php +++ b/tests/Integration/Locator/LocatorTest.php @@ -178,6 +178,26 @@ public function itEvaluatesElementTagNameAndCss(): void $this->assertEquals('50px', $width); } + #[Test] + public function itBlursAnElement(): void + { + $this->page->evaluate(<<<'JS' + () => { + const el = document.querySelector('#input-text'); + if (el) { + el.addEventListener('blur', () => { document.body.dataset.blurred = '1'; }, { once: true }); + } + } + JS); + + $locator = $this->page->locator('#input-text'); + $locator->focus(); + $locator->blur(); + + $blurred = $this->page->evaluate('() => document.body.dataset.blurred || null'); + $this->assertSame('1', $blurred); + } + private static function findFreePort(): int { return 0;