There is a button on the page which when I clicked copies, say a value to the clipboard.
I'm trying to store that value in a variable with python selenium this way:
# Clicking the button using xpath will copy the value to Clipboard
value = driver.find_element_by_xpath('//*[@id="app-content"]/div/div[4]/div/div/div/div[1]/div/div/div/button').click()
# I try to print the value using
print(value)
But I get the result as None
.
Kindly help me in doing this in correct way.
Thanks in Advance
CodePudding user response:
First of all, printing the value
is not meaningful because click()
function in Selenium doesn't return anything. You can store the text on your clipboard to a variable with this snippet:
import tkinter as tk
root = tk.Tk()
root.withdraw() # to hide the window
variable = root.clipboard_get()