I was looking at the documentation located here: https://selenium-python.readthedocs.io/getting-started.html
In the documentation, they are importing the library like this:
from selenium.webdriver.common import Keys
When I use Keys (with a capital "K"), it doesn't work (unlike what they are doing in the documentation), I get the following error message:
ImportError: cannot import name 'Keys' from 'selenium.webdriver.common
When I use this, it works:
from selenium.webdriver.common import keys
But then when I use this code:
WebElement_pw.send_keys(keys.Return)
I get the following error message:
AttributeError: module 'selenium.webdriver.common.keys' has no attribute 'RETURN'
Using Python, how can I use the Enter key with Selenium?
CodePudding user response:
I think you should import
from selenium.webdriver.common.keys import Keys
See reference here: Typing the Enter/Return key in Selenium (and it's also mentioned in the documentation that you shared)