1

我正在使用一种不允许输入重音符号的表单,但它确实允许粘贴带有重音符号的文本。

如何将文本发送到剪贴板,然后将包含重音的文本粘贴到表单中?

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
options = Options()
options.headless = True
driver = webdriver.Chrome('chromedriver.exe',options=options)

driver.get('https://www.website.com')
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, openform))).click()

send accent text to clipboard


driver.find_element(By.XPATH, formfield).send_keys(Keys.CONTROL, 'v')
4

1 回答 1

1

您可以在 python 中尝试此操作以在剪贴板中复制所需的文本,然后将其粘贴。它适用于 python 3.8。你也可以试试。如果您遇到任何问题,请告诉我。

import pyperclip
pyperclip.copy('Text to be copied to the clipboard.')
clipboard_text= pyperclip.paste()
print(clipboard_text)
于 2020-10-04T07:06:45.677 回答