Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
187 views
in Technique[技术] by (71.8m points)

python - Pasting link from clipboard to next window as a URL

I want to copy and paste clipboard link to newly opened browser tab. The fresh tab is opening but nothing is happening. Clip method in result have this url link but I got error. What I have till now :

def switch_tab(self):
        self.driver.execute_script("window.open('');")
        self.driver.switch_to.window(self.driver.window_handles[len(self.driver.window_handles) - 1])
        time.sleep(2)
        self.driver.get(clip)

and clip method

def clip():
    r = Tk()
    r.withdraw()

    while not r.selection_get(selection="CLIPBOARD"):
        time.sleep(0.1)

    result = r.selection_get(selection="CLIPBOARD")
    print(result)
    return result

File "C:UsersAppDataLocalProgramsPythonPython38libjsonencoder.py", line 179, in default
          raise TypeError(f'Object of type {o.__class__.__name__} '
      TypeError: Object of type function is not JSON serializable
question from:https://stackoverflow.com/questions/65871462/pasting-link-from-clipboard-to-next-window-as-a-url

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...