I download images from a webpage via WebDriver (Chrome) by
// STEP 1
$driver->get($link);
// STEP 2
$els=$driver->findElements(WebDriver\WebDriverBy::tagName('img'));
foreach ($els as $el) {
$src=$el->getAttribute('src');
$image=file_get_contents($src);
file_put_contents("image.jpg",$image);
}
While the images have already been loaded by the browser, I need to download the images again in STEP 2.
I can save the images after STEP 1 by right-click
in the browser and Save image as ...
without an internet connection because the images are available in the local cache of the browser.
Is it possible to save the images loaded by Chrome with WebDriver without downloading them again?
The above code is PHP
, but any hit or example codes in other programming languages can solve the problem.