Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97756

Get all image src values from website using Selenium WebDriver

$
0
0

I have a wordpress site that has thousands of image files. Problem is, vast majority are redundant and just using up disk space. I need a way to know which ones are actually referenced by the html so that I can delete those that aren't.

Maybe Selenium WebDiriver could help? I could scrape the website to get the value of src attributes of all img elements.

Using the following code, the images collection is populated with 22 items - which is correct for the particular page. Problem is, I don't know how to get to the value of the "src" attribute?

var images = driver.FindElements(By.TagName("img"));

        foreach (var image in images)
        {
            Debug.WriteLine(image.Text);
        }

Viewing all articles
Browse latest Browse all 97756

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>