How to reduce Python selenium Pyperclip.paste execution time

后端 未结 1 1343
后悔当初
后悔当初 2021-01-25 05:37

I am using following python script to copy contents from a local file and paste it into text-area, which actually works fine. However, it takes lots of time to complete this tas

1条回答
  •  孤独总比滥情好
    2021-01-25 06:03

    If your goal is solely Task Automation you could speed up the typing by writing a function and pass the element and the text setting the field directly with a script injection as follows :

    def set_text(element, text):
      element._parent.execute_script("""
        var elm = arguments[0], text = arguments[1];
        if (!('value' in elm))
          throw new Error('Expected an  or