-2
browser = webdriver.Chrome()
browser.browser.find_elements_by_xpath("//div[@class='a image']/img")

the html look like this

<div class="a image"><imgsrc="https://cloudfront.net/"></div>

how to get the src text ?

Prophet
  • 32,350
  • 22
  • 54
  • 79
ohey0
  • 1
  • https://www.tutorialspoint.com/how-do-i-get-the-src-of-an-image-in-selenium#:~:text=To%20fetch%20any%20attribute%20in,getAttribute(%22src%22). – Robert Harvey May 16 '21 at 15:29
  • https://stackoverflow.com/questions/45215992 – Robert Harvey May 16 '21 at 15:30
  • 3
    Does this answer your question? [How to get img src in string in selenium using python](https://stackoverflow.com/questions/45215992/how-to-get-img-src-in-string-in-selenium-using-python) – Sven Eberth May 16 '21 at 16:58

2 Answers2

0

Try the following:

element = browser.browser.find_elements_by_xpath("//div[@class='a image']/img")
src = element.get_attribute("src")
Prophet
  • 32,350
  • 22
  • 54
  • 79
0
print(browser.find_element_by_tag_name("img").get_attribute('src'))
Naaman
  • 62
  • 3