Skip to content Skip to sidebar Skip to footer

Paste Command Using Selenium

I'm using Python 2.7 and Selenium 2-44-0 on Windows 7. I'm looking for a quicker way of inputting text than using send_keys. Send_keys will print 1 letter at a time (which better

Solution 1:

This works:

from selenium.webdriver.common.keys import Keys

def paste_keys(self, xpath, text):
    os.system("echo %s| clip" % text.strip())
    el = self.driver.find_element_by_xpath(xpath)
    el.send_keys(Keys.CONTROL, 'v')

There cannot be a space after %s, for it will add that to the copied text.


Post a Comment for "Paste Command Using Selenium"