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. However this window closes within 30 seconds and then the copied password on the clipboard will be lost.
My intention is to save this password, copied on clipboard, into a variable to be used in later part of my python selenium code.
I'm able to successfully click this "copy" element via the automated selenium script which then copies the password to clipboard. This is my code:
''' 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()
I read an article closest to my query here, which talks about importing tkinter
module: Accessing text copied to clipboard by python
Is there a way I can do it using Selenium Webdriver methods in Python?
Please help.