0

I've been trying to input text in google textbox. Suddenly got this error. Is something modified/changed in selenium newly? Code:

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


driver = webdriver.Chrome(executable_path="C:\\Program Files (x86)\\chromedriver.exe")
driver.get("https://www.google.com/")
try:
    element = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located(By.NAME, "gLFyf")
    )
finally:
    driver.send_keys("Selenium")

error:

  File "C:\Users\bhatt\OneDrive\Desktop\Sublime\gotta_master_selenium.py", line 15, in <module>
    driver.send_keys("Selenium")
AttributeError: 'WebDriver' object has no attribute 'send_keys'

I also have some more errors

```EC.presence_of_element_located(By.NAME, "gLFyf")TypeError: presence_of_element_located() takes 1 positional argument but 2 were given

I've been looking for solution throughout the vacation. Still can't figure out the solution

2 Answers 2

1

For first error:

You have to use send_keys() function with webelement not with webdriver.

Syntax:

driver.find_element(<locator type like By.XPATH or By.ID or...>, <locator value>).send_keys("<value to enter>")

For second error:

You have to use one more parenthesis '()' in the below line:

element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.NAME, "gLFyf")))
Sign up to request clarification or add additional context in comments.

Comments

0

You can not send text send_keys("Selenium") to a web driver object driver.
Text should be sent to a specific web element you need to locate with the driver

Comments

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.