Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97792

send_keys(Keys.RETURN) is throwing an error[SOLVED]

$
0
0

I'm new to Selenium(Python). I'm trying to get the program to open google.com and type in a piece of text to be searched. Everything is fine, except it doesn't click Enter to search.

Here's the source code

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

driver = webdriver.Chrome('C:\Anaconda3\Lib\idlelib\chromedriver.exe')

driver.set_page_load_timeout("10")
driver.get("http://google.com")
driver.find_element_by_name("q").send_keys(//The piece of text)
driver.find_element_by_name("btnK").send_key(Keys.RETURN)
time.sleep(4)

And it is throwing me this error AttributeError: 'WebElement' object has no attribute 'send_key'

Can anyone tell me where I'm wrong and what I should do to fix it?


Viewing all articles
Browse latest Browse all 97792

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>