英文:
Why am I getting 'NoneType' object has no attribute 'sendkeys' error in Python 3.11.3 Selenium automation with Chrome 113.0.5672.127?
问题
I am using selenium 4.9.1, Chrome Version 113.0.5672.127 (Official Build) (64-bit)
python 3.11.3, I am trying to run a selenium function which uses sendkeys()
:
Error: Traceback (most recent call last):
File "C:\Users\DELL PC\PycharmProjects\salmanpythontest\new.py", line 10, in <module>
driver.find_element_by_id("email").sendkeys("abc@gmaail.com")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'sendkeys'
I am trying to login in a module
英文:
I am using selenium 4.9.1, Chrome Version 113.0.5672.127 (Official Build) (64-bit)
python 3.11.3, I am trying to run a selenium function which uses sendkeys()
:
Error: Traceback (most recent call last):
File "C:\Users\DELL PC\PycharmProjects\salmanpythontest\new.py", line 10, in <module>
driver.find_element_by_id("email").sendkeys("abc@gmaail.com")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'sendkeys'
I am trying to login in a module
答案1
得分: 0
"The error message you encountered, 'AttributeError: 'NoneType' object has no attribute 'sendkeys',' indicates that you are trying to use the send_keys method from the Selenium library on a variable or object of type None. This error typically occurs when the object you are trying to interact with using Selenium has not been found or initialised correctly.
Ensure that the 'email' is the right locator id you are using.
I have visited the URL, seems like the id of the locator should be 'testing' not 'email'.
英文:
The error message you encountered, "AttributeError: 'NoneType' object has no attribute 'sendkeys'," indicates that you are trying to use the send_keys method from the Selenium library on a variable or object of type None.
This error typically occurs when the object you are trying to interact with using Selenium has not been found or initialised correctly.
Ensure that the "email" is the right locator id you are using.
I have visited the URL, seems like the id of the locator should be "testing" not "email".
答案2
得分: 0
find_element_by_id
- 这个方法已经在selenium v4.3.0
及更高版本中被弃用和移除。
由于您正在使用selenium v4.9.1
,您应该使用这个方法 find_element
来替代。
所以,请将下面的代码行进行替换:
driver.find_element_by_id("email").sendkeys("abc@g.com")
替换为:
driver.find_element(By.ID, "email").send_keys("abc@gmail.com")
您需要以下导入:
from selenium.webdriver.common.by import By
英文:
find_element_by_id
- This method has been deprecated and removed from selenium v4.3.0
and onwards.
Since you are using selenium v4.9.1
, you should use this method find_element
instead.
So, replace the below line of code:
driver.find_element_by_id("email").sendkeys("abc@g.com")
To:
driver.find_element(By.ID, "email").send_keys("abc@gmail.com")
You will need below import:
from selenium.webdriver.common.by import By
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论