Chromedriver only supports characters in the BMP error while sending Emoji with ChromeDriver Chrome using Selenium Python to Tkinter's label() textbox

社会主义新天地 提交于 2020-01-28 11:13:46

问题


I am automating whatsapp messages and would like to send them out through a tkinter window. In this tkinter window I have created a message box with the help of .label() and I am able to connect to whatsapp web through selenium.

Currently, I am able to send out messages already, but without emojis. When I include emojis, I get this error "Chromedriver only supports characters in the BMP". How can I include emojis?


回答1:


This error message...

selenium.common.exceptions.WebDriverException: Message: unknown error: ChromeDriver only supports characters in the BMP

...implies that the ChromeDriver was unable to send the emoji signal through send_keys() method.

ChromeDriver only supports characters in the BMP is a known issue with Chromium team as ChromeDriver still doesn't support characters with a Unicode after FFFF. Hence it is impossible to send any character beyond FFFF via ChromeDriver. As a result any attempt to send SMP characters (e.g. CJK, Emojis, Symbols, etc) raises the error.


Alternative

A potential alternative would be to use GeckoDriver / Firefox.

  • Code Block:

    from selenium import webdriver
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
    driver = webdriver.Firefox(executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe')
    driver.get('https://www.google.com/')
    # Chineese Character
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.NAME, "q"))).send_keys("𠀀")
    # Emoji Character
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.NAME, "q"))).send_keys("💩")
    
  • Browser Snapshot:

You can find a relevant discussion in OpenQA.Selenium.WebDriverException: 'unknown error: ChromeDriver only supports characters in the BMP while sending an emoji through C# Selenium


Reference

Issue 2269: Impossible to add special characters with a unicode after FFFF


Outro

A few links:

  • Full Emoji List
  • Unicode character inspector


来源:https://stackoverflow.com/questions/59138825/chromedriver-only-supports-characters-in-the-bmp-error-while-sending-emoji-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!