我在使用Chlenmedriver with Selenium点击图片时出现以下HTML问题:
<div class="modal_buttons">
<input type="image" name="GoButton" id="GoButton" tabindex=14 title="Continue" alt="Continue" onfocus="SetLastFocus(this.id)" src="https://t4.ftcdn.net/jpg/00/81/83/05/240_F_81830511_aJbF2vH9yufF0UAUFQ83JDnbp0jE5mNV.jpg"
我尝试使用以下代码:
element = driver.find_element_by_css_selector("//div[img/@src='https://t4.ftcdn.net/jpg/00/81/83/05/240_F_81830511_aJbF2vH9yufF0UAUFQ83JDnbp0jE5mNV.jpg']").click()
Selenium每次都失败,并提供相同的错误列表,无法找到该按钮。任何想法如何解决?
由于
答案 0 :(得分:0)
尝试:
driver.find_element_by_xpath("//input[@id='GoButton'][@name='GoButton']").click()
或
driver.find_element_by_xpath("//input[@id='GoButton'][@title='Continue']").click()
或
driver.find_element_by_xpath("//input[@name='GoButton'][@title='Continue']").click()
或
driver.find_element_by_xpath("//input[contains(@src,'240_F_81830511_aJbF2vH9yufF0UAUFQ83JDnbp0jE5mNV.jpg')]")