Issue
I have one site where I can't enter a password
using send_keys
, I have to use Ctrl+V there. But I don't know how this can be done, because I have Passwords
, where all passwords are stored and I need to take it from there
from Passwords import password
#how to copy?
inputpassword = driver.find_element(By.XPATH, "Path")
inputpassword.???
#how to paste by Ctrl + V
Solution
There are 2 steps here:
- Read the text from some file into the clipboard.
- Paste from the clipboard into the web element.
There are several ways you can read a text from file into the clipboard, for example
import pyperclip
pyperclip.copy('The text to be copied to the clipboard.')
More examples and explanations can be find here and here.
Then you can simply paste the clipboard content into a web element input with Selenium with regular CTRL + V
keys
//now paste your content from clipboard
el = self.driver.find_element_by_xpath(xpath)
el.send_keys(Keys.CONTROL + 'v')
More examples and explanations can be found here or here
Answered By - Prophet
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.