是否可以使用Selenium WebDriver预先填充要粘贴的文本的剪贴板,就好像文本已在另一个应用程序中复制一样? (理想情况下使用Python绑定?)
Is it possible to use Selenium WebDriver to pre-populate the clipboard with some text to be pasted, as though the text had been copied in another application? (Ideally using the Python bindings?)
最满意答案
不,似乎没有 - 作为浏览器操作工具,Selenium旨在执行浏览器独有的功能。 通常,剪贴板操作是由文件管理器处理的功能,通常包括GUI,例如Windows资源管理器或Mac OS Finder。
各种Selenium接口(Java,Python等)可以通过多种方式访问剪贴板函数,但这些只有在有问题的浏览器在包含它们的上下文中运行时才有效。 如果Selenium运行无头(意味着没有GUI,例如使用虚拟显示器,例如Xvfb ,可能作为虚拟机的一部分),可能没有任何可访问的具有剪贴板功能的上下文,而Selenium本身并不提供任何内容。
No, it seems not – as a browser manipulation tool, Selenium is designed to perform functions unique to browsers. In general, clipboard manipulation is a function handled by a file manager, usually one which includes a GUI, such as Windows Explorer or the Mac OS Finder.
There are ways for the various Selenium interfaces (Java, Python, etc) to access clipboard functions, but these only work if the browser in question is running in a context which contains them. If Selenium is running headless (meaning with no GUI, e.g. using a virtual display such as Xvfb, possibly as part of a virtual machine) there may not be any accessible context with clipboard functionality, and Selenium itself does not provide any on its own.
更多推荐
发布评论