python - 将剪贴板中的链接作为 URL 粘贴到下一个窗口
问题描述
我想将剪贴板链接复制并粘贴到新打开的浏览器选项卡。新标签正在打开,但没有任何反应。结果中的剪辑方法具有此 url 链接,但出现错误。到目前为止我所拥有的:
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)
和剪辑方法
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:\Users\AppData\Local\Programs\Python\Python38\lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type function is not JSON serializable
解决方案
推荐阅读
- swift - 如何在将avasset当前项目URL更改为另一个URL之前存储它
- angular - Visual Studio 对装饰器的实验性支持是一项功能,在未来的发布错误中可能会发生变化
- django - 是否有任何可能的解决方案可以在 django 中的函数内部获取多个值?
- javascript - 如何在测试覆盖范围内覆盖循环内的语句
- android - 如何在 FileProvider 中保存图像(来自相机应用程序)Uri?
- python - 将 csv 中的 sqlite3 数据附加到 1 列为 - id INTEGER PRIMARY KEY AUTOINCREMENT 的表中
- java - 为什么不能直接在owlapi中使用merge来合并ABox和TBox?
- c# - 在 C# 中限制 RadListBox 中的项目重新排序
- java - 在编译时从 JSON 生成 Swift+Java 设置对象
- google-places-api - Google Place Detail 几何返回 lat lng 0