2

I have this HTML code:

<form class="_b6i0l"><textarea aria-label="Add a comment…" placeholder="Add a comment…" class="_bilrf" autocomplete="off" autocorrect="off" style="height: 18px;"></textarea>
<textarea aria-label="Add a comment…" placeholder="Add a comment…" class="_bilrf" autocomplete="off" autocorrect="off" style="height: 18px;"></textarea>
</form>

I want write a text in the filed. But, this error is happened:

selenium.common.exceptions.ElementNotInteractableException: Message: Element <textarea class="_bilrf"> is not reachable by keyboard

My code which sends the text is:

add_comment_box= WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "textarea._bilrf")))
time.sleep(5)

add_comment_box.send_keys("nice!")

Could you help me, please?

9
  • 2
    Do you have 2 textarea inside form? Commented Mar 19, 2018 at 21:17
  • No, there is just one. Commented Mar 19, 2018 at 21:22
  • 2
    @hamed baziyad, the HTML from your post has 2 textarea. Commented Mar 19, 2018 at 21:28
  • 1
    @hamed baziyad, try with a different driver. If it works then it's an issue with the driver. If not then you are either selecting the wrong element or it's a timing issue, in which case you should use a waiter to wait for the expected state or for no exception if the state can't be obtained. Commented Mar 19, 2018 at 22:09
  • 2
    @hamed baziyad, by setting the value directly, you are no longer emitting the events that the page might rely on. Thus you are no longer simulating the input from a user. It might be alright if you are scraping/automating the page, but it's not if you are testing the page. Note that your post is unlikely to be useful given that we still don't know why the element is considered not interractable by Selenium. Commented Mar 19, 2018 at 22:28

1 Answer 1

2

Rather than send_keys, we can use this section:

driver.execute_script("arguments[0].value = arguments[1]", driver.find_element_by_css_selector("textarea._bilrf"), "nice!")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.