
Question:
namespace Facebook\WebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
require_once('vendor/autoload.php');
$host = 'http://localhost:4444/wd/hub';
$options = new ChromeOptions();
I have read this <a href="https://github.com/facebook/php-webdriver/wiki/ChromeOptions" rel="nofollow">link</a> when i creating object of class ChromeOptions
getting error
PHP Fatal error: Uncaught Error: Class 'Facebook\WebDriver\ChromeOptions' not found.
</blockquote> Answer1:Try this.
$options = new Chrome\ChromeOptions();
Answer2:You are trying to instantiate ChromeOptions
, but you aren't either 'using' the class (thus making its full path visible), not declaring its full namespace + classname when instantiating it.
So your code remains consistent, you could solve this by just adding the required use
statement. E.g.:
use Facebook\WebDriver\Chrome\ChromeOptions;
Or, as Nanhe Kumar <a href="https://stackoverflow.com/a/47767561/1426539" rel="nofollow">said</a>, you could just use the fully qualified class name:
$options = new Chrome\ChromeOptions();
You could even do both, but that would be logically redundant. :)