symfony / panther

A browser testing and web crawling library for PHP and Symfony
MIT License
2.94k stars 222 forks source link

clickLink not working with special characters. #581

Open iBuaSpaz opened 1 year ago

iBuaSpaz commented 1 year ago

Hi, seems this wont work with special characters like »

This is the code

<?php
include('../vendor/autoload.php');

use PHPUnit\Framework\TestCase;
use Symfony\Component\BrowserKit\HttpBrowser;
use Symfony\Component\Panther\Client;

class PantherTest
{
    public function __construct() 
    {
    }

    function test()
    {
        try
        {
            $options = [
            '--headless',
            '--no-sandbox',
            '--disable-gpu'
            ];

            $client = Client::createChromeClient('D:\xampp\htdocs\drivers\chromedriver.exe', null, $options, null);
            $client->request('GET', 'https://www.lauritz.com/da/auktioner/?IST=0&SelectedTab=12');

            $crawler = $client->waitFor('#FooterArticleControl_BackToTopText');
            $client->takeScreenshot('screen.png'); // Yeah, screenshot!

            // remove cookie popup
            try {
                $link = $client->clickLink('Tillad alle cookies');
            }
            catch(InvalidArgumentException $e){}

            $client->clickLink('»');

            $crawler = $client->waitFor('#FooterArticleControl_BackToTopText');
            $client->takeScreenshot('screen1.png'); // Yeah, screenshot!

            print "* success <br>"; 
        }
        catch(Exception $e)
        {
            print "* Error " . var_dump($e) . "<br>";
        }
    }
}

$testclient = new PantherTest();
$testclient->test();
?>

The error is:

object(Facebook\WebDriver\Exception\ElementClickInterceptedException)#18 (8) { ["message":protected]=> string(311) "element click intercepted: Element ... is not clickable at point (345, 602). Other element would receive the click: ...

So it seems to select the menu ... instead of choosen », and the ... isnt active on first page..

menu

jumaris88 commented 10 months ago

Obviously, the element you want to click is blocked by another element. Check your page carefully.