Мне кажется, это работает, проверьте комментарии ниже:
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.maximize_window()
driver.get('https://facebook.com')
wait = WebDriverWait(driver, 10)
el = wait.until(EC.visibility_of_element_located((By.ID, "email")))
el.send_keys("username")
el = wait.until(EC.visibility_of_element_located((By.ID, "pass")))
el.send_keys("password")
el.send_keys(Keys.ENTER)
driver.refresh() # intentionally here, otherwise, in my case, was throwing an err error: "the element is no longer attached to the DOM"...
el = wait.until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Chat']")))
el.click()
el = wait.until(EC.visibility_of_element_located((By.XPATH, "//div[contains(text(), 'Kelly')]"))) # change to the full or partial friend name
el.click()
el = wait.until(EC.visibility_of_element_located((By.XPATH, "//div[contains(@class, 'notranslate')]")))
el.click()
s = "this is a sentEnce I want to send word by word"
for w in s.split():
el.send_keys(w)
el.send_keys(Keys.ENTER)
![enter image description here](https://i.stack.imgur.com/Lq2W0.jpg)