I use chrome driver to send text by send_key method in the beginning. But according to this question,chrome driver does not seem to support sending emoji. So I use a script injection to send emoji according to the link.
Here is the code, I use send_key and javascript to send text for testing:
reply_area = WebDriverWait(self.webdriver,1).until(expected_conditions.element_to_be_clickable(locator_))
reply_area.send_keys("Send_key")
JS_ADD_TEXT_TO_INPUT ="""
var element = arguments[0], txt = arguments[1];
element.value += txt;
element.dispatchEvent(new Event('change'));
"""
txt = "\n" \
"\n" \
""
self.webdriver.execute_script(JS_ADD_TEXT_TO_INPUT, reply_area, txt)
It seems work by this image. But the number of text is wrong.
And after I click the text area on the website, only the text sent by send_key() is left.
I know I can use GeckoDriver to send emoji by send_key() according to this, but I want to understand thoroughly, and it seems work by the comment left below the question. The website I tested can only be seen when you are a seller, so I can't provide the url for testing.
Thank you All.
[Updated] Here is the html.
<div data-v-4e626831="" class="reply-comment">
<div data-v-4e626831="" class="shopee-input shopee-input__area">
<textarea type="textarea" placeholder="Please enter your reply" resize="none" rows="2" minrows="2" maxlength="500" restrictiontype="input" class="shopee-input__inner shopee-input__inner--normal" style="resize: none; min-height: 71px;"></textarea>
</div>
<div data-v-4e626831="" class="des">30/500</div> <!-- This is the number of word -->
</div>