puphpeteer
puphpeteer copied to clipboard
Using puppeteers page.select() function in puphpeteer
Hello,
I am using "nesk/puphpeteer": "^2.0"
and I want to select the following dropdown of a datatable:
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!
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!