How can I send text to text editor with Python Selenium?

Viewed 90

I want to send a text to the post editor with Selenium, but I have a problem with xpaths, how can I solve it?

Error code:

DeprecationWarning: find_element_by_* commands are deprecated. Please use find_element() instead element = driver.find_element_by_xpath("/html/body").send_keys(DETAIL)

My Code

element = driver.find_element_by_xpath("/html/body").send_keys(DETAIL)

The part where I want to send the text

enter image description here

1 Answers
driver.find_element_by_xpath("/html/body").send_keys(DETAIL)

should be due to depreciate also import by.

driver.find_element(By.CSS_SELECTOR,".cke_editable.cke_editable_themed.cke_contents_ltr").send_keys(DETAIL)

You also have an iframe so switch to that first.

WebDriverWait(driver,30).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,".cke_wysiwyg_frame.cke_reset")))

Imports:

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