2

我正在使用带有 Laravel 框架的 Symfony Panther。我在使用这个时遇到了错误

未知错误:无法为用户数据目录创建临时目录 {"exception":"[object] (Facebook\WebDriver\Exception\UnknownErrorException(code: 0):

我已经为 Windows 7.4.2 安装了 XAMPP。

PHP:7.4.2,阿帕奇:2.4.41

作曲家.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 控制器类

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):未知错误:无法在 D:\WWW\PHP\myproject\vendor\php-webdriver\webdriver\lib\Exception\WebDriverException.php:139 为用户数据目录创建临时目录

4

1 回答 1

0
  1. 检查您的磁盘是否没有空间不足。

  2. XAMPP 是否具有正确的权限?它可能需要以提升的权限运行。

  3. 检查%TEMP%%TMP%环境变量并确保它们存在。(为此,请在 Windows 命令行上运行echo %TEMP%和)echo %TMP%

相关: 不以管理员身份运行时出现“无法为用户数据目录创建临时目录”错误

于 2020-02-27T18:38:51.857 回答