EdgeDriver only supports characters in the BMP?

be chan 0 Reputation points
2024-09-01T14:14:08.35+00:00

EdgeDriver only supports characters in the BMP. So many emojis may be invalid.

Microsoft Edge
Microsoft Edge
A Microsoft cross-platform web browser that provides privacy, learning, and accessibility tools.
2,357 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ShiJieLi-MSFT 10,271 Reputation points Microsoft Vendor
    2024-09-02T02:44:53.13+00:00

    Hi @be chan ,

    Unfortunately, ChromeDriver (EdgeDriver) only supports characters in the BMP is a known issue, but till now the support for other characters has not been added yet.

    However, you can use the following workaround to add emojis:

    JS_ADD_TEXT_TO_INPUT = """
      var elm = arguments[0], txt = arguments[1];
      elm.value += txt;
      elm.dispatchEvent(new Event('change'));
      """
    driver = webdriver.Edge()
    driver.get("https://google.com/")
    elem = driver.find_element("xpath", "//textarea[@name='q']")
    text = "🌎"
    driver.execute_script(JS_ADD_TEXT_TO_INPUT, elem, text)
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards,

    Shijie Li

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.