我正在使用Ruby gem Rautomation测试一个基于windows的应用程序。该应用程序在远程Citrix服务器后面运行,因此我无法以通常的方式与该应用程序交互。我不能使用像windows inspect.exe这样的刮板来访问应用程序上的任何元素。我想做的是使用键盘和/或鼠标选择应用程序上的文本,然后将其复制到文件中进行验证。
下面是我想做的代码片段:
window = RAutomation::Window.new(:title => /Manager App/i, :adapter => 'ms_uia')
window.move_mouse(60,95)
window.click_mouse_and_hold # is there a 'hold' method??
window.move_mouse(80,95)
window.release_mouse # is there a 'release' method??
window.send_keys [:left_control, 'c']或
window.move_mouse(60,95)
window.click
window.send_keys :shift # hold this key down somehow??
window.move_mouse(80,95)
window.release_shift # is there a 'release' key method??
window.send_keys [:left_control, 'c']我想要做的是拖动鼠标在这个应用程序上选择一段文本,或者选择一些文本的开头,按住Shift键,然后选择我需要的文本的结尾。基本上复制了用户在现实生活中选择和复制文本的方式,但通过Rautomation。这个是可能的吗?
谢谢
发布于 2017-01-14 20:23:09
我还没有测试过它,但是使用win32和autoit适配器,您应该能够使用Mouse#press和Mouse#release来实现它。下面是用于以下内容的a spec:
it "#press/#release" do
window = RAutomation::Window.new(:title => "MainFormWindow")
window.maximize
text_field = window.text_field(:index => 2)
text_field.set("start string")
text_field.value.should == "start string"
mouse = window.mouse
mouse.move :x => 146, :y => 125
mouse.press
mouse.move :x => 194
mouse.release
window.send_keys [:control, "c"]
text_field.set("new string")
text_field.value.should == "new string"
mouse.move :x => 146
mouse.press
mouse.move :x => 194
mouse.release
window.send_keys [:control, "v"]
text_field.value.should == "start string"
end请查看documentation for RAutomation,为您提供更多帮助。
https://stackoverflow.com/questions/41619866
复制相似问题