Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page->querySelector doesn't work #8

Closed
sylvainlepetit opened this issue Nov 22, 2023 · 2 comments
Closed

Page->querySelector doesn't work #8

sylvainlepetit opened this issue Nov 22, 2023 · 2 comments

Comments

@sylvainlepetit
Copy link

sylvainlepetit commented Nov 22, 2023

Describe the bug

The variable $page returned by $browser->newPage(); (see code below) is not a Page \Nesk\Puphpeteer\Resources\Page but a Nesk\Rialto\Data\BasicResource. So functions like querySelector doesn't work (like all methods from Page)

Reproducible example

 $options = [
    'args' => [
        '--no-sandbox',
        '--disable-web-security',
        '--disable-setuid-sandbox',
        '--allow-file-access-from-files',
    ],
    'log_browser_console' => true,
    'log_node_console' => false,
    'debug' => false,
];

$puppeteer = new Puppeteer($options);
$browser = $puppeteer->launch([
    'headless' => 'new',
    'defaultViewport' => ['width' => 1920, 'height' => 1080]
]);
$page = $browser->newPage();
$page->goto($url);
$page->emulateMediaType('screen');
// $page->waitForTimeout(2000);
$page->waitForSelector(self::SELECTOR_CHART_ARE_LOADED);
$tableau = $page->querySelector('.position-relative');

Exception returned: [Nesk\Rialto\Exceptions\Node\FatalException] "CDPPage.querySelector is not a function"

Begin of the dump of $page:
image

NB: My code was previously writed for nesk/puphpepeteer and I try to switch.

@sylvainlepetit
Copy link
Author

The problem come from a bad install version (1.6.0).

@meyer59
Copy link

meyer59 commented Mar 27, 2024

Hey
I am facing the same issue, my install seems fine though, how did you manage to solved this precisely?
Thanks

mreiden added a commit to mreiden/puphpeteer that referenced this issue Aug 21, 2024
 - Update requirements to PHP 8.3, Node 18.0, puppeteer 22
 - Use relative paths for .mjs imports and no longer require node packages
 - Remove Frame->ExecutionContext() [Puppeteer v17]
 - Rename Page->createIncognitoBrowserContext() to Page->createBrowserContext() [Puppeteer v22]
 - Remove CDP (case-insensitve) from puppeteer classes in responses (CdpBrowser, etc) [Solves zoonru#8 and zoonru#11]
 - Add PHP strict_types declarations
 - Update phpunit to 11.3 fix tests to run
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

No branches or pull requests

2 participants