Search on blog:

Selenium: How to send clipboard to field in browser

When you find input field on page then you can send Ctrl+V to send text from clipboard to this field.

import selenium.webdriver
from selenium.webdriver.common.keys import Keys 

driver = selenium.webdriver.Firefox()
driver.get('https://google.com')

item = driver.find_element_by_name('q')
item.send_keys(Keys.CONTROL + "v")
#item.send_keys(Keys.CONTROL, "v")

You can also try to select and copy to clipboard text but it may works only with visible text, and it can work with <body> (to get all text) but it may have problem with other elements (to get only part of text).

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("http://quotes.toscrape.com")

element = driver.find_element_by_tag_name("body")

# it gets only visible text.
# it works with <body> but not have to with other tags.
element.send_keys(Keys.CONTROL, "a")
element.send_keys(Keys.CONTROL, "c")

You can also try to use pyperclip to get text from clipboard and send it as normal text.

import pyperclip

#pyperclip.copy('The text to be copied to the clipboard.')

text = pyperclip.paste()
#print(text)

import selenium.webdriver
from selenium.webdriver.common.keys import Keys 

driver = selenium.webdriver.Firefox()
driver.get('https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_textarea')

frame = driver.find_element_by_id('iframeResult')
driver.switch_to.frame(frame)

item = driver.find_element_by_id('w3mission')
item.clear()
item.send_keys(text)
If you like it
Buy a Coffee