【问题标题】:RAutomation Drag Mouse and Select TextRAutomation 拖动鼠标并选择文本
【发布时间】:2017-05-27 22:55:24
【问题描述】:

我正在使用 Ruby gem Rautomation 来测试基于 Windows 的应用程序。该应用程序在远程 Citrix 服务器后面运行,因此我无法以通常的方式与该应用程序交互。我无法使用诸如 windows inspect.exe 之类的刮刀访问应用程序上的任何元素。我想做的是使用键盘和/或鼠标在应用程序上选择文本,然后将其复制到文件中以进行验证。

这是我想做的代码sn-p:

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

谢谢

【问题讨论】:

    标签: ruby rautomation


    【解决方案1】:

    我还没有测试过,但是使用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 为您提供更多帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-02-25
      • 1970-01-01
      • 1970-01-01
      • 2016-02-05
      • 2015-10-10
      • 2014-02-10
      • 2017-12-27
      相关资源
      最近更新 更多