Skip to content

Commit b0cda81

Browse files
committed
bug: waitForCondition() log playwright exception
1 parent 2bf8b18 commit b0cda81

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/Browser/BrowserContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function newPage(array $options = []): PageInterface
171171
throw new ProtocolErrorException('No valid pageId returned from transport in newPage', 0);
172172
}
173173

174-
$page = new Page($this->transport, $this, $response['pageId'], $this->config, $this->config->logger);
174+
$page = new Page($this->transport, $this, $response['pageId'], $this->config);
175175
$this->pages[$response['pageId']] = $page;
176176

177177
return $page;

src/Locator/Locator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ private function waitForCondition(callable $condition, int $timeoutMs, string $m
657657
return;
658658
}
659659
} catch (PlaywrightException $e) {
660+
$this->logger->error($e->getMessage());
660661
}
661662

662663
usleep(100000);

src/Page/Page.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ final class Page implements PageInterface, EventDispatcherInterface
7878

7979
private PageEventHandlerInterface $eventHandler;
8080

81+
private LoggerInterface $logger;
82+
8183
private ?APIRequestContextInterface $apiRequestContext = null;
8284

8385
private bool $isClosed = false;
@@ -92,8 +94,10 @@ public function __construct(
9294
private readonly BrowserContextInterface $context,
9395
private readonly string $pageId,
9496
private readonly PlaywrightConfig $config,
95-
private readonly LoggerInterface $logger = new NullLogger(),
97+
?LoggerInterface $logger = null,
9698
) {
99+
$this->logger = $logger ?? $config->logger ?? new NullLogger();
100+
97101
$this->keyboard = new Keyboard($this->transport, $this->pageId);
98102
$this->mouse = new Mouse($this->transport, $this->pageId);
99103
$this->eventHandler = new PageEventHandler();

0 commit comments

Comments
 (0)