Panther How can I specify the Navigator or User Agent

September 22, 2021 . 1 MIN READ

https://github.com/symfony/panther/issues/141

 

You can pass an array of arguments when creating the client with createChromeClient(). which avoids the above problem with space being a delimiter. The arguments will be used instead of calling getDefaultArguments(), so if you want to keep any defaults you must also set them here.

In this example the user agent is custom, and window-size/headless/disable-gpu are set to match the current defaults.

$client = \Symfony\Component\Panther\Client::createChromeClient(null, [ ‘–user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36’, ‘–window-size=1200,1100’, ‘–headless’, ‘–disable-gpu’, ]);

Leave a Reply

Your email address will not be published. Required fields are marked *