[英]Send text to clipboard in selenium
I am working with a form that does not allow to type accents, but it does allow to paste text with accent.我正在使用一个不允许输入重音的表单,但它允许粘贴带有重音的文本。
How can I send text to the clipboard, then paste the text containing accent into the form?如何将文本发送到剪贴板,然后将包含重音的文本粘贴到表单中?
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')
You could try this in python to copy the desired text in clipboard and then pasting it.您可以尝试在 python 中复制剪贴板中所需的文本,然后粘贴它。 It is working with python 3.8.
它正在使用 python 3.8。 You can try it too.
你也可以试试。 if you face any issue then let me know.
如果您遇到任何问题,请告诉我。
import pyperclip
pyperclip.copy('Text to be copied to the clipboard.')
clipboard_text= pyperclip.paste()
print(clipboard_text)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.