panther icon indicating copy to clipboard operation
panther copied to clipboard

Is it possible for symfony/panther to wait for some elements n times?

Open woei66 opened this issue 3 years ago • 1 comments

Below is my PHP code and I am looking for a custom callback function that I need to make sure I can get more than 5 elements with css identifier "a[data-selenium='neighbor-link']" and I will fetch the html content.

Is it possible? Thank you.

$client = \Symfony\Component\Panther\Client::createChromeClient(null, $options2);
$client->request('GET', $row['url']);
$client->waitFor("a[data-selenium='neighbor-link']");

There is similar behavior of php-webdriver . You can see the "Custom conditions" on github.com/php-webdriver/php-webdriver/wiki/HowTo-Wait The sample usage is :

$driver->wait()->until( function () use ($driver) { 
   $elements = $driver->findElements(WebDriverBy::cssSelector('li.foo')); 
   return count($elements) > 5; }, 
'Error locating more than five elements' ); 

woei66 avatar Apr 07 '21 03:04 woei66

OMG @woei66 it's included to waitFor :) Did you read function ? Second parameter = overal timeout - waiting time, Third = ask interval All this included in box

/** * @param string $locator The path to an element to be waited for. Can be a CSS selector or Xpath expression. * * @throws NoSuchElementException * @throws TimeoutException * * @return Crawler */ public function waitFor(string $locator, int $timeoutInSecond = 30, int $intervalInMillisecond = 250)

Mepcuk avatar May 31 '21 13:05 Mepcuk