RAutomation 拖动鼠标和 Select 文本

RAutomation Drag Mouse and Select Text

我正在使用 Ruby gem Rautomation 来测试基于 windows 的应用程序。该应用程序在远程 Citrix 服务器后面 运行,因此我无法以通常的方式与该应用程序交互。我无法使用像 windows inspect.exe 这样的抓取工具访问应用程序上的任何元素。我想做的是使用键盘 and/or 鼠标到应用程序上的 select 文本,然后将其复制到文件以进行验证。

这是我想做的代码片段:

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']

我想做的是将鼠标拖动到此应用程序的 select 一段文本,或者 select 一些文本的开头,按住 shift,然后 select我需要的文字的结尾。基本上复制用户在现实生活中 select 和复制文本的方式,但通过 Rautomation。这可能吗?

谢谢

我还没有测试过,但是使用 win32autoit 适配器你应该可以使用 Mouse#pressMouse#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 以帮助您更多。