2017-06-29 68 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