Created
October 21, 2011 23:30
-
-
Save stirno/1305261 to your computer and use it in GitHub Desktop.
Ruby Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'json' | |
require 'net/http' | |
require 'uri' | |
teststeps = [ | |
{ | |
:name => "Open", | |
:arguments => { | |
:url => "http://www.google.com/" | |
} | |
}, | |
{ | |
:name => "Enter", | |
:arguments => { | |
:selector => "input[title='Search']", | |
:value => "Fluent Automation" | |
} | |
}, | |
{ | |
:name => "ExpectValue", | |
:arguments => { | |
:selector => "input[title='Search']", | |
:valueExpression => 'x.Contains("ent Auto") && x.Length > 6' | |
} | |
}, | |
{ | |
:name => "Click", | |
:arguments => { | |
:selector => "button[value='Search']" | |
} | |
}, | |
{ | |
:name => "Wait", | |
:arguments => { | |
:seconds => 1 | |
} | |
} | |
] | |
jsonData = teststeps.to_json() | |
service = Net::HTTP.new("10.0.1.8", 10001) | |
request = Net::HTTP::Post.new("/runtest") | |
request['content-type'] = 'application/json' | |
request.body = jsonData | |
responseBody = service.request(request).body | |
print responseBody | |
print "\n\n" | |
jsonResponse = JSON.parse(responseBody) | |
print jsonResponse['Status'] | |
if jsonResponse['Message'] != nil | |
print "\n" | |
print jsonResponse['Message'] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment