Paste command using Selenium

后端 未结 1 1390
不知归路
不知归路 2020-12-17 03:58

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 (whi

相关标签:
1条回答
  • 2020-12-17 04:09

    This works:

    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.

    0 讨论(0)
提交回复
热议问题