0

我正在使用 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 复制用户在现实生活中选择和复制文本的方式。这可能吗?

谢谢

4

1 回答 1

0

我还没有测试过它,但是使用win32andautoit适配器你应该能够使用Mouse#pressand来做到这一点Mouse#release。这是一个规格

  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

查看RAutomation 的文档以帮助您获得更多帮助。

于 2017-01-14T12:23:08.613 回答