如何在Chromeoptions中禁用图像加载?(PHP库(
我尝试了以下内容,但不确定语法是否正确
$options = new ChromeOptions();
// disable images
$options->addArguments(array(
"service_args=['--load-images=no']"
));
$caps = DesiredCapabilities::chrome();
$caps->setCapability(ChromeOptions::CAPABILITY, $options);
$driver = RemoteWebDriver::create($host, $caps);
禁用,使用参数: --blink-settings=imagesEnabled=false
$options->addArguments(array(
'--blink-settings=imagesEnabled=false'
));
https://github.com/facebook/php-webdriver/issues/641#issuecomment-51255496
在以下示例之后留下以后的参考:
这是有效的:
$capabilities = DesiredCapabilities::chrome();
$capabilities->setCapability('acceptInsecureCerts', true);
$capabilities->setCapability(ChromeOptions::CAPABILITY_W3C, [
'args' => [
'--blink-settings=imagesEnabled=false',
]
]);
这也是有效的:
$options = new ChromeOptions();
$options->addArguments(
[
'--blink-settings=imagesEnabled=false',
]
);
$result = DesiredCapabilities::chrome();
$result->setCapability(
ChromeOptions::CAPABILITY_W3C,
$options->toArray() // Notice that ->toArray() is used
);
以下内容不起作用:
$options = new ChromeOptions();
$options->addArguments(
[
'--blink-settings=imagesEnabled=false',
]
);
$result = DesiredCapabilities::chrome();
$result->setCapability(
ChromeOptions::CAPABILITY_W3C,
$options // Notice that ->toArray() is NOT used
);