In the below code, I want to check if the element is present at XPath, then only it should execute code.
if($browser->driver->findElement(WebDriverBy::xpath('/html/body/div[1]/div/section/div[3]/div[2]/div/table/tbody/tr['.$i.']/td[2]'))!==null)
{
$sort=$browser->driver->findElement(WebDriverBy::xpath('/html/body/div[1]/div/section/div[3]/div22]/div/table/tbody/tr['.$i.']/td[2]'))->gettext();
echo $sort;
}
Or else please suggest if there is another way to check element is present in laravel dusk. P.S. I tried whenAvailable method but it couldn't help me in this case.
Found another better and workable solution:
if ($browser->element('#IDString')) {
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With