简体   繁体   English

在硒中将文本发送到剪贴板

[英]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.

相关问题 运行硒时如何在Mac上从剪贴板粘贴文本-Python - How to paste text from clipboard on mac while running selenium - Python Selenium 使用 unicode 表情符号发送文件中的文本 - Selenium send text in file with unicode emoji Python selenium send_keys 中断文本 - Python selenium send_keys brokes text Python Selenium 在文本字段中发送文本的正确方法是什么? - What is the correct way in Python Selenium to send text in text field? 如何使用Python硒脚本将Array发送到文本框? - How to send Array to a text box with Python selenium scripting? Kivy 将按钮文本复制到剪贴板 - Kivy copy button text to clipboard 在Python中将突出显示的文本复制到剪贴板 - Copying highlighted text to clipboard in Python 如何使用 selenium python send_keys 将表格 dataframe 发送到网页的文本区域? - How to send tabulated dataframe to text area of webpage using selenium python send_keys? 从剪贴板复制文本,在剪贴板内容前后添加文本,然后将结果复制回剪贴板 - Copy text from clipboard, add text before and after clipboard content, then copy result back into clipboard 将突出显示的文本复制到剪贴板,然后使用剪贴板将其附加到列表中 - Copy highlighted text to clipboard, then use the clipboard to append it to a list
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM