这就是我所拥有的
for arrow in self.driver.find_elements_by_xpath("//img[contains(@src, 'disclosure_closed.gif')]/"):
arrow.click()
但它把这个扔给我了
^{pr2}$我也试过这样做:
image_url = "http://example.com/disclosure_closed.gif"
for arrow in self.driver.find_elements_by_xpath("//img[@src='%s']/" %(image_url)):
arrow.click()
这是html:
<img align="top" style="cursor:pointer;" onclick="disclose('44');" id="44disclosure" src="http://example.com/disclosure_closed.gif">
删除xpath末尾的
/
。在看来你已经得到答案了。但您不需要为该标识符使用xpath。xpath比css慢,而且(通常)也不那么可靠。您可以使用以下css选择器来标识同一个元素:
或者(特别是图像)
^{pr2}$相关问题 更多 >
编程相关推荐