I need send emoticons with selenium, for example:
���������✊🏿�🏿�🏿�🏼�🏻�����
and selenium returns an error, I tested with .send_keys(unicode(bio_text, 'ascii')) # iso-8859-1, the same result.
How can I send these characters with python selenium?
python code:
driver.find_element_by_id("biography").clear()
driver.find_element_by_id("biography").send_keys(unicode('���������✊🏿�🏿�🏿�🏼�🏻�����', 'ascii')) # iso-8859-1
emoticons example :
���������✊🏿�🏿�🏿�🏼�🏻�����
解决方案
Here is what i did.
# -*- coding: utf-8 -*-
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('https://google.com')
text = u"😀😁'😂'😇😺"
text = text.replace("'", "\\'") # escape single quotes
text = text.encode('utf-8') # needed to make format function work
driver.execute_script(
"document.getElementById('lst-ib').value = '{data}'".format(
data=text
))