<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>实际上,您的<code>xpath</code>在语法上不正确,您缺少右括号<code>]</code>,因此您应该尝试如下:</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>或使用<code>css_selector</code>作为:-</p>
^{pr2}$
<p>如果要打印所有<code>img</code>src属性,请尝试如下方式:-</p>
<pre><code>images = driver.find_elements_by_tag_name("img")
for image in images :
print(image.get_attribute("src"))
</code></pre>