Selenium Python Webdriver chrome print src's of all imgs
<p>I want to print all src of imgs in the page, i want to see if it recognize it,
cuz when i do </p>

<pre><code>driver.find_element_by_xpath("//img[@src='http://images.yad2.co.il/Pic/site_images/yad2/MyYad2/images/myorderbottom/new/jump_ad.png'").click()
</code></pre>

<p>its says:</p>

<pre><code>    C:\Users\Bar\AppData\Local\Programs\Python\Python35-32\python.exe C:/Users/Bar/PycharmProjects/yad2/Webdriver.py
Traceback (most recent call last):
  File "C:/Users/Bar/PycharmProjects/yad2/Webdriver.py", line 14, in &lt;module&gt;
    driver.find_element_by_xpath("//img[@src='http://images.yad2.co.il/Pic/site_images/yad2/MyYad2/images/myorderbottom/new/jump_ad.png'").click()
  File "C:\Users\Bar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 293, in find_element_by_xpath
    return self.find_element(by=By.XPATH, value=xpath)
  File "C:\Users\Bar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 752, in find_element
    'value': value})['value']
  File "C:\Users\Bar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Bar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression //img[@src='http://images.yad2.co.il/Pic/site_images/yad2/MyYad2/images/myorderbottom/new/jump_ad.png' because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//img[@src='http://images.yad2.co.il/Pic/site_images/yad2/MyYad2/images/myorderbottom/new/jump_ad.png'' is not a valid XPath expression.
  (Session info: chrome=52.0.2743.116)
  (Driver info: chromedriver=2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129),platform=Windows NT 6.1.7601 SP1 x86_64)
</code></pre>

<p>I have tried with <code>css_selector</code> , didn't work , so I want to print all of the srcs of the <code>imgs</code>, how can I do that?</p>

<blockquote>
  <p>selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression //img[@src='<a href="http://images.yad2.co.il/Pic/site_images/yad2/MyYad2/images/myorderbottom/new/jump_ad.png" rel="nofollow">http://images.yad2.co.il/Pic/site_images/yad2/MyYad2/images/myorderbottom/new/jump_ad.png</a>' because of the following error:
  SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//img[@src='<a href="http://images.yad2.co.il/Pic/site_images/yad2/MyYad2/images/myorderbottom/new/jump_ad.png" rel="nofollow">http://images.yad2.co.il/Pic/site_images/yad2/MyYad2/images/myorderbottom/new/jump_ad.png</a>'' is not a valid XPath expression.</p>
</blockquote>

<p>Actually your <code>xpath</code> is syntactically incorrect, you are missing to close square bracket <code>]</code>, So you should try as :-</p>

<pre><code>driver.find_element_by_xpath(".//img[@src='http://images.yad2.co.il/Pic/site_images/yad2/MyYad2/images/myorderbottom/new/jump_ad.png']").click()
</code></pre>

<p>Or using <code>css_selector</code> as :-</p>

<pre><code>driver.find_element_by_css_selector("img[src='http://images.yad2.co.il/Pic/site_images/yad2/MyYad2/images/myorderbottom/new/jump_ad.png']").click()
</code></pre>

<p>And if you want to print all <code>img</code> src attribute try as :-</p>

<pre><code>images = driver.find_elements_by_tag_name("img")
for image in images :
  print(image.get_attribute("src"))
</code></pre>

python selenium selenium-webdriver