Let us say, I loaded a URI with selenium. I have no idea how the elements are named in that page (I do not know the id, name ... of elements). I want to download all the possible pictures that may exist on that webpage. This problem is solved through the first answer of this question. But how can I located with selenium all the pictures that exist on that webpage ?
I checked answers for similar questions like this one but the answers are not useful.
Asked
Active
Viewed 2,437 times
0

Community
- 1
- 1
2 Answers
1
The easiest way is to find by tag name as all images will have an image tag you can just get every element on that page with that tag. In python i believe it will be using (note note find_element_by_tag_name as that would return just one of the elements)
find_elements_by_tag_name
and you will want to find elements with the img tag http://www.w3schools.com/tags/tag_img.asp

Paul Harris
- 5,769
- 1
- 25
- 41
-
Yes, but I do not have the names and ids of those pictures (it is an automated process, I can not do it by hand) – Jul 22 '14 at 09:57
-
1You do not need the id or names tag is part of the html structure of a page and will be what all images on the page are embedded in so by searching via tag you will final all the elements with that tag which will be all the pictures – Paul Harris Jul 22 '14 at 09:58
-
Ok, I will run a small script and test your solution. Regards. – Jul 22 '14 at 09:59
-
2you dont need to know any id, name, just find_element_by_tag_name('img') and you will have all images in page – Nguyen Vu Hoang Jul 22 '14 at 10:02
-
The problem with this solution is that using find_elements_by_tag_name with img is that it will not find background images set in the css.. – Linus J Sep 13 '22 at 08:19
0
If I'm not mistaken, you can do something like this
driver.find_element_by_tag_name('img')
Hope that's help.

Heaven42
- 329
- 1
- 13