eggPlant Drive and Ruby

I’ve been writing scripts in Ruby that will take advantage of eggPlant Drive, but I’m clearly doing something wrong. I’m new to both eggPlant and Ruby. This is on OSX 10.7.5

Here’s a few lines of script that will demonstrate the problem:

require "xmlrpc/client"

client = XMLRPC::Client.new "127.0.0.1:5400"
client.call("StartSession", "Users/Tim.Espasandin/Documents/evaluation.suite")

It looks like I’ve got eggPlant running in Drive mode:

2013-06-11 09:57:58.955 runscript[616:4707] OCR enabled-unlimited usage
2013-06-11 09:58:01.660 runscript[616:d03] Approved License: Name = Tim Espasandin, Remark = , Serial = 24324, Users = 1
runscript (12.21-1305192358) running in CLI mode on Host:12011206.
2013-06-11 09:58:01.706 runscript[616:d03] Starting eggPlant Drive on port 5400...

When I try to pass the “StartSession”, I a wordy error:

/Users/Tim.Espasandin/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/http.rb:878:in `initialize': getaddrinfo: nodename nor servname provided, or not known (SocketError)
	from /Users/Tim.Espasandin/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/http.rb:878:in `open'
	from /Users/Tim.Espasandin/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/http.rb:878:in `block in connect'
	from /Users/Tim.Espasandin/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/timeout.rb:66:in `timeout'
	from /Users/Tim.Espasandin/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/http.rb:877:in `connect'
	from /Users/Tim.Espasandin/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
	from /Users/Tim.Espasandin/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/http.rb:857:in `start'
	from /Users/Tim.Espasandin/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/xmlrpc/client.rb:474:in `do_rpc'
	from /Users/Tim.Espasandin/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/xmlrpc/client.rb:281:in `call2'
	from /Users/Tim.Espasandin/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/xmlrpc/client.rb:262:in `call'
	from XMLTest.rb:4:in `<main>'

Can anyone tell what I’m doing wrong here?

I think the problem is that the path to your suite is not relative to the current working directory. If you intended to start the path at the system root then you need to start it with a slash:

client.call("StartSession", "/Users/Tim.Espasandin/Documents/evaluation.suite")

Here’s a sample Ruby script (that assumes eggPlant Drive is running on a Windows machine):

require "xmlrpc/client"

# Make an object to represent the XML-RPC server.
server = XMLRPC::Client.new("192.168.3.102",nil,5400)

# try to end any existing session
begin 
    result = server.call("EndSession")
    puts result
rescue
   # doesn't really matter if above failed -- no action required 
end

# Call the remote server and start a session
result = server.call("StartSession","c:\\Users\\Support\\Documents\	esting.suite")
puts result

# Establish a connection from eggPlant to a SUT
result = server.call("Execute", "Connect (serverID:\"192.168.3.128\", password:\"eggplanet\")")
output = result["Output"]
# see what the result of the moveto was
puts "MoveTo output: #{output}"

# Execute a moveto command with an existing image
result = server.call("Execute", "MoveTo ChromeShortcut")
output = result["Output"]
# see what the result of the moveto was
puts "MoveTo output: #{output}"

# Execute a script that returns a text value
result = server.call("Execute", "Run DriveTest")
output = result["Result"]
# see what the result returned by the script was
puts "Script output: #{output}"


# End the remote session
result = server.call("EndSession")
puts result

Note that I wrote this while learning just enough Ruby to write it, so while it works, a Ruby expert could doubtless improve on it.

It didn’t look like that the slash made a difference, but I noticed that your code was passing the port as a separate argument from the ip. I went ahead and re-did my arguments to copy the way that you were using them, and things are working much better now!

Thanks for the help!