2017-04-12 234 views
0

我嘗試在我的Wlan Repeater上登錄並重新啓動它,它登錄並進入「重新啓動」按鈕所在的站點,可惜Selenium沒有找到該按鈕。 這就是按鈕:無法在Selenium Python中找到元素

<button type="submit" name="reboot">Neu starten</button> 

但如果我試試這個:

reboot = browser.find_element_by_name('reboot') 
reboot.submit() 

我得到以下錯誤:

selenium.common.exceptions.NoSuchElementException: Message: no such element: 
Unable to locate element: {"method":"name","selector":"reboot"} 
+0

'.find_element_by_xpath(「// button [@ name ='reboot']」)''? –

+0

也不起作用 – MushroomMauLa

+0

它是否在'iframe'內? –

回答

0

有可能是該例外多種原因。

  • 元素在不同的幀
  • 你有錯誤的網頁上登陸了(某種斷言將有助於)
  • 頁面沒有加載,你正在努力尋找元素(顯式wait方法將幫助在這種情況下)
  • 標識符是錯誤的(這不是你的情況)

調查這些事情,你會找出解決辦法。

+0

Im在右頁,它是也加載(我認爲?),我的意思是我可以單擊按鈕,由於該網站是開放和加載 – MushroomMauLa

+0

http://imgur.com/a/e6Jhe這裏是證明我在正確的網站 – MushroomMauLa

+0

@MushroomMauLa也可能是iframe的情況,並嘗試使用明確的等待。我告訴你幾個可能性,不要只堅持一個。 –