unknown error: cannot create temp dir for user data dir in Laravel with Symfony Panther

Viewed 402

i am using Symfony Panther with Laravel framework. I got an error while using this

unknown error: cannot create temp dir for user data dir {"exception":"[object] (Facebook\WebDriver\Exception\UnknownErrorException(code: 0):

I have installed XAMPP for Windows 7.4.2.

PHP: 7.4.2, Apache: 2.4.41

composer.json

"require": {
        "php": "^7.1.3",
        "fabpot/goutte": "^3.2",
        "fideloper/proxy": "^4.0",
        "guzzlehttp/guzzle": "~6.0",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0",
        "symfony/css-selector": "^4.4",
        "symfony/http-client": "^4.4",
        "symfony/panther": "^0.7.0"
    }

Laravel Controller Class

namespace App\Http\Controllers;

include (base_path() .'/vendor/autoload.php');
use Illuminate\Http\Request;
use Symfony\Component\DomCrawler\Crawler;

use Symfony\Component\BrowserKit\HttpBrowser;
use Symfony\Component\HttpClient\HttpClient;

class PageController extends Controller
{
    public function myFunction(Request $request)
    {
        $client = \Symfony\Component\Panther\Client::createChromeClient();

        $client->request('GET', 'https://api-platform.com'); // Yes, this website is 100% written in JavaScript
        $client->clickLink('Support');

        // Wait for an element to be rendered
        $crawler = $client->waitFor('.support');

        echo $crawler->filter('.support')->text();
    }
}

[2020-02-27 16:12:21] local.ERROR: unknown error: cannot create temp dir for user data dir {"exception":"[object] (Facebook\WebDriver\Exception\UnknownErrorException(code: 0): unknown error: cannot create temp dir for user data dir at D:\WWW\PHP\myproject\vendor\php-webdriver\webdriver\lib\Exception\WebDriverException.php:139)

1 Answers
  1. Check that your disk is not running low on space.

  2. Does XAMPP have the correct permissions? It may be required to run with elevated permissions.

  3. Check the %TEMP% and %TMP% environment variables and ensure they exist. (To do this, run echo %TEMP% and echo %TMP% on the Windows' command line)

Related: "cannot create temp dir for user data dir" error when not running as admin

Related