1
導入密鑰我試圖執行下面的代碼。我專門嘗試從webdriver導入Keys,但它仍然不起作用。需要幫助從selenium.webdriver.common.keys
from selenium import webdriver
import selenium.webdriver.common.keys
driver = webdriver.Firefox()
page = driver.get("https://www.python.org/")
print (driver.title)
finder = driver.find_element_by_class_name("search-field")
finder.send_keys("Python Test")
finder.send_keys(Keys.RETURN)
輸出:
Welcome to Python.org
Traceback (most recent call last):
File "C:/Users/Arvind/Desktop/Python Tests/selenium_tests.py", line 9, in
<module>
finder.send_keys(Keys.RETURN)
NameError: name 'Keys' is not defined
>>>
工程就像一個魅力!謝謝!!! –