这在 php-webdriver 1.11.0 (2021-05-03) 中得到了改进。启动无头 Chrome$chromeOptions = new ChromeOptions();$chromeOptions->addArguments(['--headless']);$capabilities = DesiredCapabilities::chrome();$capabilities->setCapability(ChromeOptions::CAPABILITY_W3C, $chromeOptions);// Start the browser with $capabilities// A) When using RemoteWebDriver::create()$driver = RemoteWebDriver::create($serverUrl, $capabilities);// B) When using ChromeDriver::start to start local Chromedriver$driver = ChromeDriver::start($capabilities);有关更多 Chrome 示例,请参阅 php-webdriver wiki 文章。启动无头 Firefox$firefoxOptions = new FirefoxOptions();$firefoxOptions->addArguments(['-headless']);$capabilities = DesiredCapabilities::firefox();$capabilities->setCapability(FirefoxOptions::CAPABILITY, $firefoxOptions);// Start the browser with $capabilities// A) When using RemoteWebDriver::create()$driver = RemoteWebDriver::create($serverUrl, $capabilities);// B) When using FirefoxDriver::start to start local Geckodriver$driver = FirefoxDriver::start($capabilities);