Home > other >  i receive an error: AttributeError: 'WebElement' object has no attribute 'sendkeys�
i receive an error: AttributeError: 'WebElement' object has no attribute 'sendkeys�

Time:12-08

i have this code on a practise page:

**from selenium import webdriver
driver = webdriver.Chrome(executable_path="G:\Selenium Testing\Drivers\chromedriver.exe")
driver.get("https://rahulshettyacademy.com/AutomationPractice/")
driver.maximize_window()
driver.find_element_by_css_selector("#name").send_keys("option3")**

and i receive this error:

***driver.find_element_by_css_selector("#name").sendkeys("option3")
AttributeError: 'WebElement' object has no attribute 'sendkeys'***

please help me with this

i also tried using this import statement:

***from selenium.webdriver.common.keys import Keys***

CodePudding user response:

In python it is

send_keys

not

sendkeys("option3")

sendkeys("option3") is basically in Selenium - Java bindings.

so your effective code would be:

driver.find_element_by_css_selector("#name").send_keys("option3")

CodePudding user response:

Can you try:

driver.find_element_by_id("name").send_keys("option3")

I've just tested it in the console, and it works for me.

EDIT:

Actually, find_element_by_css_selector("#name") works too, so the problem lies somewhere else...

Perhaps do a driver.find_element_by_css_selector("#name").click() first, and then send_keys("option3")

  • Related