Python Selenium Code To Save Text In A Variable From Clipboard Which Is Copied To The Clipboard By Click Of An Element
On my webpage I have a window as shown in the image below. It has a division which shows the password. When I click on the 'copy' element, it copies the password onto the clipboard
Solution 1:
tkinter
comes in shipped by default with python3, contrary to what I was thinking, and using it is pretty simple:
My adding of last 2 code-lines to the previous code mentioned in my question, worked like charm:
''' I will change time.sleep() later to appropriate WebdriverWait. This is just for test. '''''' This also means that I will have to save the copied password from clipboard within 10seconds, '''''' before the window closes '''
time.sleep(20)
copy_button = self.chrome_driver.find_element_by_xpath('//div[@class="button__container__not-show-spinner"]/div[@class="button__text"]')
copy_button.click()
root = tk.Tk()
print(root.clipboard_get())
Ofcourse you have to import the tkinter
for this to work, and in my case this is the import statement I used:
import tkinter as tk
Post a Comment for "Python Selenium Code To Save Text In A Variable From Clipboard Which Is Copied To The Clipboard By Click Of An Element"