Khan Saad
Khan Saad

Reputation: 966

python selenium send_key() is not working

i am new at automation. i am trying to enter a sting in the text box of Omegle and press enter but it is showing me an error :

selenium.common.exceptions.ElementNotInteractableException: Message: Element is not reachable by keyboard

here is the webpage link where i wanna access the text box.

import time
import random
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By

driver = webdriver.Firefox()

driver.get("https://www.omegle.com/")
time.sleep(random.randint(2, 5))
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(random.randint(1, 5))
button = driver.find_element(By.XPATH, "//span[@class='topicplaceholder']")
button.click()
button.send_keys("panda")
button.send_keys(Keys.RETURN)

Upvotes: 1

Views: 457

Answers (2)

Issam El Missaoui
Issam El Missaoui

Reputation: 76

I've tried this, it's working.

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

browser = webdriver.Chrome()
browser.get("https://www.omegle.com/")
text_area = browser.find_element_by_class_name("topicplaceholder")
text_area.click()
input = browser.find_element_by_class_name("newtopicinput")
input.send_keys("panda")
input.send_keys(Keys.RETURN)

I hope having solved your matter.

Upvotes: 2

ccan23
ccan23

Reputation: 11

Should work:

button = driver.find_element_by_xpath('/html/body/div[3]/table/tbody/tr[2]/td[1]/div/div/div[1]/span[2]')
button.click()
button.send_keys('panda')
button.send_keys(u'\ue007')

Upvotes: 1

Related Questions