'python selenium no element to send_keys

I just started studying selenium, so please understand if there is any mistake. Thankyou :)

I would like to crawling a site where can create a blog called 'tistory' through selenium.

In order to create an article, you must choose one of the default mode, markdown mode, or html mode.

Basic mode is possible. enter image description here

iframe=driver.find_element_by_css_selector('iframe')
driver.switch_to.frame(iframe)
driver.find_element_by_id('tinymce').send_keys("test text")

But I want to do is html mode, so I created a code that can automatically write through selenium in html mode. enter image description here

text_box = driver.find_element_by_css_selector("#html-editor-container > div.mce-edit-area > div > div > div:nth-child(1) > textarea")
text_box.send_keys("test text")

another element textarea

text_box = driver.find_element_by_css_selector("div.ReactCodemirror>textarea")
text_box.send_keys("test text")

An error appears when I try to run it.

selenium.common.exceptions.ElementNotInteractableException: Message: element (Session info: chrome=99.0.4844.74)

Regarding the error, I think the textarea element is an incorrect element for writing text, but I don't know what is the correct element.

this is html mode html. enter image description here

This problem has been bothering me for three days. Please solve this problem. I beg you.



Solution 1:[1]

In HTML mode, you don't see an iframe?

or

Since in Basic mode you switched to an iframe, did you switch to default content?

to solve

selenium.common.exceptions.ElementNotInteractableException: Message: element (Session info: chrome=99.0.4844.74)

You should debug your code like below:

  1. Make sure the browser is launched in full screen using

    driver.maximize_window()
    
  2. Use ActionChains:

    ActionChains(driver).move_to_element(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "div.ReactCodemirror>textarea")))).send_keys('something here').perform()
    
  3. Use execute_script:

    text_area = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.ReactCodemirror>textarea")))
    driver.execute_script("arguments[0].setAttribute('value', 'write something here')", text_area)
    

Imports:

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cruisepandey