2017-06-29 67 views
0
我在点击使用与硒的Chromedriver以下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

我相信隐含的等待 –

+0

你能展示完整的Python代码文件吗? –

回答

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')]") 
+0

我得到了和以前一样的错误...它仍然找不到元素 –

+0

你看到什么错误? – DebanjanB

+0

尝试更新的代码行 – DebanjanB