メインコンテンツまでスキップ

Eggdriveを使用したRubyスクリプトの例

この例では、RubyスクリプトでEggdriveを使用する方法を示しています。Eggdriveの使用方法について詳しくは、Eggdriveの使用を参照してください。

require "xmlrpc/client"

# XML-RPCサーバーを表すオブジェクトを作成します。
server = XMLRPC::Client.new("192.168.3.102",nil,5400)

# 既存のセッションを終了しようとします
begin
result = server.call("EndSession")
puts result
rescue

# 上記が失敗しても問題ありません -- 何もアクションは必要ありません
end

# リモートサーバーを呼び出し、セッションを開始します
result = server.call("StartSession", "c:\\Users\Support\Documents\testing.suite")
puts result

# eggPlantからSUTへの接続を確立します
result = server.call("Execute", "Connect (serverID:\"192.168.3.128\", password:\"eggplanet\")")
output = result["Output"]

# movetoの結果を確認します
puts "MoveTo output: #{output}"

# 既存の画像でmovetoコマンドを実行します
result = server.call("Execute", "MoveTo ChromeShortcut")
output = result["Output"]

# movetoの結果を確認します
puts "MoveTo output: #{output}"

# テキスト値を返すスクリプトを実行します
result = server.call("Execute", "Run DriveTest")
output = result["Result"]

# スクリプトが返す結果を確認します
puts "Script output: #{output}"

# リモートセッションを終了します
result = server.call("EndSession")
puts result