Php-webdriver: autoload.php error

Created on 22 Apr 2020  路  6Comments  路  Source: php-webdriver/php-webdriver

What are you trying to achieve? (Expected behavior)

I'm trying to run example.php test. autoload.php exist.

What do you get instead? (Actual behavior)

PHP Fatal error:  require_once(): Failed opening required 'vendor/autoload.php' (include_path='.;C:\php-7.2.29-Win32-VC15-x64\pear') in C:\Users\...\tests\FirstTest.php on line 12

How could the issue be reproduced? (Steps to reproduce)

FirstTest.php

<?php

use Facebook\WebDriver\Chrome\ChromeDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;

require_once("vendor/autoload.php");
$host = 'http://localhost:9515/wd/hub';
putenv('WEBDRIVER_CHROME_DRIVER=chromedriver.exe');
$driver = ChromeDriver::start();
$driver->get('https://en.wikipedia.org/wiki/Selenium_(software)');

composer.json

{
    "require": {
        "php-webdriver/webdriver": "^1.8"
    }
}

php.ini

include_path=".;C:\php-7.2.29-Win32-VC15-x64\pear"

Details

  • PEAR Version: 1.10.12
  • Php-webdriver version: 1.8.2
  • PHP version: 7.2.29
  • Operating system: Win 10
  • Browser used + version: Chrome 81

All 6 comments

did you composer install ?

@williamdes yes
In addition: Now that I run the test via the command line

php FirstTest.php

everything works, but when I try to run through PHPStorm, an error still appears.

Try require_once __DIR__ . '/vendor/autoload.php';
I hope It will fix the error in both cases

@williamdes
Structure of my project is
image

require_once(__DIR__ . '..\vendor\autoload.php');

give me the same error

https://www.php.net/manual/en/language.constants.predefined.php

__DIR__ | The directory of the file. If used inside an include, the directory of the included file is returned. This is equivalent to聽dirname(__FILE__). This directory name does not have a trailing slash unless it is the root directory.
-- | --

I think you are missing the first slash

@williamdes oh thx)

Was this page helpful?
0 / 5 - 0 ratings