S
S
seoplus20192021-03-01 22:39:32
PHP
seoplus2019, 2021-03-01 22:39:32

HeadlessChromium for php how to make click?

I use the HeadlessChromium library for php, tell me how to make click through xpath.
I bring my code

require_once('vendor/autoload.php');

use HeadlessChromium\BrowserFactory;
use HeadlessChromium\Input\Mouse;
use HeadlessChromium\Communication\Connection;
use HeadlessChromium\Communication\Message;

$browserFactory = new BrowserFactory("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe");
// starts headless chrome
$browser = $browserFactory->createBrowser([
    'headless'        => true,         // disable headless mode
   'windowSize' => [663, 558],
    'enableImages' => false,
    'sendSyncDefaultTimeout' => 30000000,

    'mouse' => true // will enable verbose mode
]);
$page = $browser->createPage();

$uri = 'https://saite.ru';
$page->navigate($uri)->waitForNavigation();
$pageTitle = $page->evaluate('document.title')->getReturnValue();
echo $pageTitle;


$evaluation = $page->evaluate('document.documentElement.innerHTML')->getReturnValue();

echo $evaluation;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daria Motorina, 2021-03-02
@glaphire

Judging by the sorts of the Page class, there is no way, but you can try creating click events on elements through javascript and run this code through $page->evaluate. Google for "javascript fire click event"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question