gpt4 book ai didi

ruby - 如何访问剪贴板数据以实现自动化?

转载 作者:数据小太阳 更新时间:2023-10-29 08:00:25 25 4
gpt4 key购买 nike

我正在使用 selenium webdriver 和 ruby​​。长话短说,我正在开发一个 Web 应用程序,该应用程序单击一个按钮即可将文本字段中的所有数据复制到剪贴板。我想访问该数据并比较是否存在字符串。

我已经安装了剪贴板和 win32/clipboard gems。这是我的代码

include Win32 
abc = Clipboard.data
em = " ooyalaPlayer = OO.Player.create('playerContainer',"
puts 'true' if abc.include? em

这是错误堆栈

$ jruby tests/embed_add_remove_playlist.rb -b firefox -a staging
ui-test-support will place screenshots and additional logs under:
results_dir=E:/testing/behavioral_tests/themebuilder/results
c:/jruby-1.7.4/lib/ruby/shared/rubygems/custom_require.rb:36: Use RbConfig inste
ad of obsolete and deprecated Config.
LoadError: no such file to load -- win32-clipboard
require at org/jruby/RubyKernel.java:1054
require at c:/jruby-1.7.4/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at E:/testing/behavioral_tests/themebuilder/lib/embed_helper.rb:8
require at org/jruby/RubyKernel.java:1054
require at c:/jruby-1.7.4/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at tests/embed_add_remove_playlist.rb:8

最佳答案

首先安装“win32-clipboard”:

gem install win32/clipboard

然后执行以下操作:

require 'win32-clipboard'
include Win32

abc = Clipboard.data
puts abc

关于ruby - 如何访问剪贴板数据以实现自动化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17470787/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com