2017-01-12 17 views
0

Ruby gem Rautomationを使用して、Windowsベースのアプリケーションをテストしています。アプリケーションがリモートのCitrixサーバーの背後で実行されているため、通常の方法でアプリケーションと対話できません。私は窓inspect.exeのようなスクレーパーを使ってアプリ上の要素にアクセスすることはできません。私がしたいのは、キーボードやマウスを使ってアプリ上のテキストを選択し、それを検証のためにファイルにコピーすることです。ここでRAutomationマウスをドラッグしてテキストを選択

は私がやりたいもののコードスニペットです:

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

私がやりたい何この上のテキストのセクションを選択するために、マウスをドラッグしていますアプリ、またはいくつかのテキストの開始を選択し、シフトを保持し、私は必要なテキストの終わりを選択します。実際にはテキストを選択してコピーする方法を基本的に再現しますが、Rautomationを使用します。これは可能ですか?

おかげ

答えて

0

私はそれをテストしていませんが、win32autoitアダプタを使用すると、Mouse#pressMouse#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 

チェックアウトdocumentation for RAutomationさらにあなたを助けるために:ここではa specためです。

関連する問題