How to scroll to element using Symfony Panther without executing javascript?

1.3k Views Asked by At

I want to scroll to an element using Symfony Panther but without using the javascript method.

Does anybody know a way to do that?

The javascript method is something like this:

<?php

// autoload here

$client = Client::createChromeClient();

$client->executeScript('document.getElementById("someElementId").scrollIntoView();');
1

There are 1 best solutions below

0
On BEST ANSWER

Use the client that is the representations of the browser. For instance:

$client = Client::createChromeClient();
$client->getKeyboard()->pressKey(WebDriverKeys::PAGE_DOWN); 

of course as you can interact with the mouse or keyboard to scroll down in the browser there are also other possibilities how can you do that. The PageDown is just an example

There are many more interesting functions inside just check the sources