我正在查看位于此處的檔案:https ://selenium-python.readthedocs.io/getting-started.html
在檔案中,他們正在像這樣匯入庫:
from selenium.webdriver.common import Keys
當我使用 Keys(帶有大寫“K”)時,它不起作用(不像他們在檔案中所做的那樣),我收到以下錯誤訊息:
ImportError: cannot import name 'Keys' from 'selenium.webdriver.common
當我使用它時,它可以作業:
from selenium.webdriver.common import keys
但是當我使用這段代碼時:
WebElement_pw.send_keys(keys.Return)
我收到以下錯誤訊息:
AttributeError: module 'selenium.webdriver.common.keys' has no attribute 'RETURN'
使用 Python,如何在 Selenium 中使用 Enter 鍵?
uj5u.com熱心網友回復:
我認為你應該匯入
from selenium.webdriver.common.keys import Keys
請參閱此處的參考:在 Selenium 中鍵入 Enter/Return 鍵 (您共享的檔案中也提到了它)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/463170.html
標籤:Python python-3.x 硒
