-4

I'm new python (programming). Currently working on a project to fill up forms using selenium and python.

So for everything seems okay. I successfully installed python 3.6, selenium on pycharm and chrome drive on my windows.

I try to open a website and fill the form using the script. The script opens the site but couldn't put the texts in the form.

I have been browsing stack overflow and googling for hours and anything doesn't work.

It shows error regarding sendkeys.

Here's the full code

from selenium import webdriver

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import time

# Replace below path with the absolute path
# to chromedriver in your computer
driver = webdriver.Chrome('C:\\Users\public\chromedriver.exe')


# Go to your page url
driver.get('https://www.website.com/')

# Get button you are going to click by its id ( also you could us find_element_by_css_selector to get element by css selector)
button_element = driver.find_element_by_class_name('signup_email_link')
button_element.click()

input_element = driver.find_element_by_name("first_name")
input_element.sendkeys(ram)

Here's the error code,

C:\Users\user\AppData\Local\Programs\Python\Python36-32\python.exe "C:/Users/user/PycharmProjects/My Projects/My scripts automate.py"
Traceback (most recent call last):
  File "C:/Users/user/PycharmProjects/My Projects/My scripts automate.py", line 22, in <module>
    input_element.sendkeys(ram)
AttributeError: 'WebElement' object has no attribute 'sendkeys'

Process finished with exit code 1

I even tried to replace the input_element with web_element but error continuous.

I use latest Python 3.6 version on pycharm.

6
  • 5
    Possible duplicate of Python Selenium - AttributeError : WebElement object has no attribute sendKeys Commented Apr 28, 2017 at 13:07
  • No, it's different question bro Commented Apr 28, 2017 at 13:09
  • Does send_keys not work? Commented Apr 28, 2017 at 13:11
  • No, bro it doesn't Commented Apr 28, 2017 at 13:15
  • 1
    I've read the other parts.. It does work, you have a different error because of the undefined variable "ram". So therefore your original question was a duplicate.. Commented Apr 28, 2017 at 13:15

2 Answers 2

2

Use

input_element.send_keys(ram)

instead of

input_element.sendkeys(ram)
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Sithling. but not working. Here's the error, C:\Users\user\AppData\Local\Programs\Python\Python36-32\python.exe "C:/Users/user/PycharmProjects/My Projects/My scripts automate.py" Traceback (most recent call last): File "C:/Users/user/PycharmProjects/My Projects/My scripts automate.py", line 22, in <module> input_element.send_keys(ram) NameError: name 'ram' is not defined Process finished with exit code 1
@Joel you need to define ram, looking at your code there is no mention of the ram variable.
2

It should be input_element.send_keys(ram).

List of methods here.

11 Comments

Thanks for your answer Mazjin.
Here's the error, C:\Users\user\AppData\Local\Programs\Python\Python36-32\python.exe "C:/Users/user/PycharmProjects/My Projects/My scripts automate.py" Traceback (most recent call last): File "C:/Users/user/PycharmProjects/My Projects/My scripts automate.py", line 22, in <module> input_element.send_keys(ram) NameError: name 'ram' is not defined Process finished with exit code 1
With the underscore included? Does it give a different error message?
@Joel you need to define ram, looking at your code there is no mention of the ram variable.
Ah, well you just need to set ram to a string containing whichever characters you need to send, or replace it with said string, ie. ram='some string' input_element.ssend_keys(ram) or input_element.send_keys('some string'
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.