首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RAutomation拖动鼠标并选择文本

RAutomation拖动鼠标并选择文本
EN

Stack Overflow用户
提问于 2017-01-13 01:54:32
回答 1查看 121关注 0票数 0

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

下面是我想做的代码片段:

代码语言:javascript
复制
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']

代码语言:javascript
复制
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。这个是可能的吗?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-01-14 20:23:09

我还没有测试过它,但是使用win32autoit适配器,您应该能够使用Mouse#pressMouse#release来实现它。下面是用于以下内容的a spec

代码语言:javascript
复制
  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,为您提供更多帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41619866

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档