Selenium/python 2.7 如何查找只有标题的元素?

Selenium/python 2.7 How to find element that only has a title?

我是 selenium 的新手,我试图点击一个图像,但是当我检查该元素时,它只有一个标题、一个 src= 和一个 alt=。我想使用 xpath 但不确定它在 python 上的确切工作方式,在 java 上我会使用 driver.findElement(By.xpath("//img[@title='']")) 但我不确定如何在 python 上使用感谢帮助:)

在Python中有find_element_by_xpath()快捷方式:

driver.find_element_by_xpath("//img[@title='']")

请注意,您的定位器看起来不太可靠。提供图像及其父图像的相关 HTML 可能有助于我们为您提供更好的选择。