0

I am using the Ruby gem Rautomation to test a windows based application. The application is running behind a remote Citrix server and therefore I am not able to interact with the app in the usual way. I cannot access any elements on the app using a scraper like windows inspect.exe. What i would like to do is use the keyboard and/or mouse to select text on the app, and then copy it to a file for verification purposes.

Here is a code snippet of what i would like to do:

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

OR

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

What I would like to do is drag the mouse to select a section of text on this app, OR select the start of some text, hold shift, then select the end of the text i need. Basically replicating how a user would select and copy text in real life but through Rautomation. Is this possible?

Thanks

Austin L
  • 336
  • 1
  • 17

1 Answers1

0

I have not tested it, but with win32 and autoit adapters you should be able to do it with Mouse#press and Mouse#release. Here's a spec for:

  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

Check out documentation for RAutomation to help you even more.

Jarmo Pertman
  • 1,905
  • 1
  • 12
  • 19