Naik
Naik

Reputation: 1255

How to select image in Selenium

I need to download the six images in this link in the zoomed version.

https://www.venus.com/viewproduct.aspx?BRANCH=7~63~&ProductDisplayID=71352

But if you take a look at the HTML, you will find out that just the first one is in the selected mode. I can simply click on the rest of them and change the class to the selected and then download all of them. How can I do this automatically using selenium?

Upvotes: 0

Views: 99

Answers (1)

Amith YR
Amith YR

Reputation: 172

In the page you can get the original image source from the preview images.

previewImages = driver.find_elements_by_xpath("//div[@class='previews']//img")
for origImages in previewImages:
    previewurl=origImages.get_attribute("src")
    local_image_filename = wget.download(previewurl.replace("?preset=productalt",""))
    print(local_image_filename)

Above code gets the original image url from preview images and downloads them using wget. You need to import wget for this to work.

Upvotes: 1

Related Questions