2015-06-01 33 views
-1

這是我用硒測試的html標記(類似於瓷磚的對象)的外觀。Chrome webdriver不讓我點擊漢堡菜單

enter image description here

測試的目的是通過點擊圖標漢堡包如所附截圖看到觸發下拉菜單。

下面是相關代碼

dropdown_menu = tile.find_element_by_class_name('dropdown-toggle') 
    dropdown_menu.click() 

當涉及到click函數調用,我得到這個錯誤:

WebDriverException: Message: unknown error: Element is not clickable at point (528, 125). Other element would receive the click: <span class="icon-file"></span> 

icon-file類是上左上角的藍色圖標瓷磚。

但是,當我在firefox中測試相同的代碼時,我沒有得到這個異常。

行爲差異的可能原因是什麼?

+1

有一個[錯誤報告](HTTPS: //code.google.com/p/selenium/issues/detail?id=2766)與此主題有一定聯繫。似乎一個元素必須在它的中心點擊,而漢堡菜單可能不是這種情況。我建議你通讀主題並檢查這是否適用於你的案例。注意。它似乎沒有發生在Firefox上,只有Chrome .. – Peanut

回答

0

我加在兩線之間的time.sleep(5),它解決了該問題

dropdown_menu = tile.find_element_by_class_name('dropdown-toggle') 
time.sleep(5) 
dropdown_menu.click() 

感謝Peanut爲他的鏈接錯誤報告在他的評論