1

I am trying to run a PHP program through terminal in ubuntu16.04

while running the code I go following error:-

vyclean06@vyclean06-desktop:/var/www/html$ php php_sele.php
PHP Warning:  include(/php-webdriver/PHPWebDriver/webdriver.php): failed to open stream: No such file or directory in /var/www/html/php_sele.php on line 3
PHP Warning:  include(): Failed opening '/php-webdriver/PHPWebDriver/webdriver.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/php_sele.php on line 3
PHP Fatal error:  Uncaught Error: Class 'PHPWebDriver_WebDriver' not found in /var/www/html/php_sele.php:6
Stack trace:
#0 {main}
  thrown in /var/www/html/php_sele.php on line 6

Here is my PHP file :-

<?php
// include dirname(__FILE__)."/php-webdriver/PHPWebDriver/webdriver.php";
include "/php-webdriver/PHPWebDriver/webdriver.php";
$wd_host = 'http://localhost:4444/wd/hub';
$web_driver = new PHPWebDriver_WebDriver($wd_host);
$session = $web_driver->session('firefox');
?>

Code is in same directory where the library folder is kept i.e. in /var/www/html/

Suppose I used dirname(__FILE__) same error thrown

vyclean06@vyclean06-desktop:/var/www/html$ php php_sele.php
PHP Warning:  include(/var/www/html/php-webdriver/PHPWebDriver/webdriver.php): failed to open stream: No such file or directory in /var/www/html/php_sele.php on line 2
PHP Warning:  include(): Failed opening '/var/www/html/php-webdriver/PHPWebDriver/webdriver.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/php_sele.php on line 2
PHP Fatal error:  Uncaught Error: Class 'PHPWebDriver_WebDriver' not found in /var/www/html/php_sele.php:6
Stack trace:
#0 {main}
  thrown in /var/www/html/php_sele.php on line 6

I am using PHP 7.0...

What should be done by me to encounter the error...?

Thank You in Advance :)

Shreejay Pendse
  • 194
  • 2
  • 13
  • Try removing the leading `/` as that says go back to the root directory and then start looking up the directory structure from there – RiggsFolly Sep 06 '16 at 07:58
  • Getting same error @RiggsFolly , I am not getting `PHP Warning: include(): Failed opening '/var/www/html/php-webdriver/PHPWebDriver/webdriver.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/php_sele.php on line 2` what exactly it means – Shreejay Pendse Sep 06 '16 at 09:17
  • Does that file exist in that directory? Does the account that the webserver is running under have persissions to access it – RiggsFolly Sep 06 '16 at 09:22
  • What directory is the script in? – RiggsFolly Sep 06 '16 at 09:22
  • my code contains at `/var/www/html/` and library where file `WebDriver.php` is kept at `/var/www/html/php-webdriver/PHPWebDriver/WebDriver.php`. `WebDriver.php` containing class PHPWebDriver_WebDriver – Shreejay Pendse Sep 06 '16 at 09:42
  • Then `include "php-webdriver/PHPWebDriver/webdriver.php";` should work – RiggsFolly Sep 06 '16 at 09:43

0 Answers0