Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Locator/Locator.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public function locator(string $selector): self
$newSelectorChain = clone $this->selectorChain;
$newSelectorChain->append($selector);

return new Locator($this->transport, $this->pageId, $newSelectorChain, $this->frameSelector);
return new Locator($this->transport, $this->pageId, $newSelectorChain, $this->frameSelector, $this->logger);
}

/**
Expand Down Expand Up @@ -657,6 +657,7 @@ private function waitForCondition(callable $condition, int $timeoutMs, string $m
return;
}
} catch (PlaywrightException $e) {
$this->logger->error($e->getMessage());
}

usleep(100000);
Expand Down
8 changes: 6 additions & 2 deletions src/Page/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ final class Page implements PageInterface, EventDispatcherInterface

private PageEventHandlerInterface $eventHandler;

private LoggerInterface $logger;

private ?APIRequestContextInterface $apiRequestContext = null;

private bool $isClosed = false;
Expand All @@ -92,8 +94,10 @@ public function __construct(
private readonly BrowserContextInterface $context,
private readonly string $pageId,
private readonly PlaywrightConfig $config,
private readonly LoggerInterface $logger = new NullLogger(),
?LoggerInterface $logger = null,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove it from here and use only the one from config, and in confing spawn the null one by default.

) {
$this->logger = $logger ?? $config->logger ?? new NullLogger();

$this->keyboard = new Keyboard($this->transport, $this->pageId);
$this->mouse = new Mouse($this->transport, $this->pageId);
$this->eventHandler = new PageEventHandler();
Expand Down Expand Up @@ -204,7 +208,7 @@ public function locator(string $selector, array|LocatorOptions $options = []): L
$this->pageId,
$selector,
null,
null,
$this->logger,
$this->normalizeLocatorOptions($options)
);
}
Expand Down