Ph.*_*lpp 1 python selenium google-chrome selenium-chromedriver
当出现以下错误时,我尝试使用 python 和 Selenium Chrome 驱动程序发送表情符号:
selenium.common.exceptions.WebDriverException: Message: unknown error: ChromeDriver only supports characters in the BMP
(Session info: chrome=86.0.4240.75)
Run Code Online (Sandbox Code Playgroud)
我已经研究这个主题一段时间了,并在 @GalBracha 的另一个问题中在 C# 中找到了以下解决方法。
由于我根本不懂 C# 并且对 Selenium 也不太熟悉,所以我想问是否有人知道 Python 中的类似解决方案。
谢谢
小智 6
通过将文本复制到剪贴板,然后将其粘贴到元素中,可以很容易地解决这个问题。

import pyperclip
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
driver.get("https://google.com")
title = driver.title
assert title == "Google"
driver.implicitly_wait(0.5)
search_box = driver.find_element(by=By.NAME, value="q")
pyperclip.copy("Hi This is a test message ! ")
act = ActionChains(driver)
act.key_down(Keys.CONTROL).send_keys("v").key_up(Keys.CONTROL).perform()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2963 次 |
| 最近记录: |