Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

Using puppeteers page.select() function in puphpeteer #158

Open
marcpre opened this issue Nov 17, 2021 · 1 comment
Open

Using puppeteers page.select() function in puphpeteer #158

marcpre opened this issue Nov 17, 2021 · 1 comment

Comments

@marcpre
Copy link

marcpre commented Nov 17, 2021

Hello,

I am using "nesk/puphpeteer": "^2.0" and I want to select the following dropdown of a datatable:

image

Find below my minimum example:

<?php

require_once '../vendor/autoload.php';

use Nesk\Puphpeteer\Puppeteer;
use Nesk\Rialto\Data\JsFunction;

$debug = true;

$puppeteer = new Puppeteer([
    'read_timeout' => 100,
    'debug' => $debug,
]);
$browser = $puppeteer->launch([
    'headless' => !$debug,
    'ignoreHTTPSErrors' => true,
]);

$page = $browser->newPage();
$page->goto('https://www.psacard.com/auctionprices#0%7Cpokemon');

// select dropdown
// drop-down activate
$selectElemDropDown = $page->querySelectorXPath('//*[@id="DataTables_Table_0_length"]/label/select');
$selectElemDropDown[0]->click();
$selectElemOptTwo = $page->querySelectorXPath('//*[@id="DataTables_Table_0_length"]/label/select/option[2]');
$selectElemOptTwo[0]->click();

$browser->close();

I tried clicking on the dropdown and then clicking again to select the element, which does not work.

I puppeteer JS there is a function called page.select(selector, ...values).

How can I do this function in puphpteer in my minimum viable example?

I appreciate your replies!

@chisphefo
Copy link

Hi,
Inspect element "Per Page" in your link given at https://www.psacard.com/auctionprices#0%7Cpokemon

I think you should try Select method by Selector like this:

$page->select('[name="DataTables_Table_0_length"]', '100');

Good luck!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants