留下以下更完整的示例以供将来参考:
这是有效的:
$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
);