Skip to content

Instantly share code, notes, and snippets.

@stirno
Created October 21, 2011 23:30
Show Gist options
  • Save stirno/1305261 to your computer and use it in GitHub Desktop.
Save stirno/1305261 to your computer and use it in GitHub Desktop.
Ruby Test
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