Reputation: 5446
How do you disable image loading in ChromeOptions? (PHP library)
I tried the following but not sure if syntax is correct
$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);
Upvotes: 2
Views: 798
Reputation: 2388
Leaving following fuller examples for future reference:
This is what works:
$capabilities = DesiredCapabilities::chrome();
$capabilities->setCapability('acceptInsecureCerts', true);
$capabilities->setCapability(ChromeOptions::CAPABILITY_W3C, [
'args' => [
'--blink-settings=imagesEnabled=false',
]
]);
This is what also works:
$options = new ChromeOptions();
$options->addArguments(
[
'--blink-settings=imagesEnabled=false',
]
);
$result = DesiredCapabilities::chrome();
$result->setCapability(
ChromeOptions::CAPABILITY_W3C,
$options->toArray() // Notice that ->toArray() is used
);
The following does NOT work:
$options = new ChromeOptions();
$options->addArguments(
[
'--blink-settings=imagesEnabled=false',
]
);
$result = DesiredCapabilities::chrome();
$result->setCapability(
ChromeOptions::CAPABILITY_W3C,
$options // Notice that ->toArray() is NOT used
);
Upvotes: 2
Reputation: 90
To disable, use the argument: --blink-settings=imagesEnabled=false
$options->addArguments(array(
'--blink-settings=imagesEnabled=false'
));
https://github.com/facebook/php-webdriver/issues/641#issuecomment-512255496
Upvotes: 2