gondola 1.1.1 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +50 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +62 -0
- data/bin/gondola +46 -49
- data/gondola.gemspec +80 -0
- data/lib/gondola.rb +1 -0
- data/lib/gondola/converter.rb +196 -199
- data/lib/gondola/tester.rb +71 -74
- data/lib/gondola/testrunner.rb +93 -98
- data/lib/gondola/version.rb +9 -0
- data/test/helper.rb +18 -0
- data/test/test_gondola.rb +7 -0
- metadata +62 -17
- data/LICENSE +0 -19
- data/README.markdown +0 -0
data/.document
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
childprocess (0.1.7)
|
5
|
+
ffi (~> 0.6.3)
|
6
|
+
cmdparse (2.0.3)
|
7
|
+
ffi (0.6.3)
|
8
|
+
rake (>= 0.8.7)
|
9
|
+
git (1.2.5)
|
10
|
+
highline (1.6.1)
|
11
|
+
jeweler (1.5.2)
|
12
|
+
bundler (~> 1.0.0)
|
13
|
+
git (>= 1.2.5)
|
14
|
+
rake
|
15
|
+
json (1.5.1)
|
16
|
+
json_pure (1.5.1)
|
17
|
+
mime-types (1.16)
|
18
|
+
net-ssh (2.1.3)
|
19
|
+
net-ssh-gateway (1.0.1)
|
20
|
+
net-ssh (>= 1.99.1)
|
21
|
+
parallel (0.5.2)
|
22
|
+
rake (0.8.7)
|
23
|
+
rest-client (1.6.1)
|
24
|
+
mime-types (>= 1.16)
|
25
|
+
rubyzip (0.9.4)
|
26
|
+
sauce (0.17.6)
|
27
|
+
childprocess (>= 0.1.6)
|
28
|
+
cmdparse (>= 2.0.2)
|
29
|
+
highline (>= 1.5.0)
|
30
|
+
json (>= 1.2.0)
|
31
|
+
net-ssh
|
32
|
+
net-ssh-gateway
|
33
|
+
rest-client
|
34
|
+
selenium-webdriver (>= 0.1.2)
|
35
|
+
selenium-webdriver (0.1.3)
|
36
|
+
childprocess (~> 0.1.5)
|
37
|
+
ffi (~> 0.6.3)
|
38
|
+
json_pure
|
39
|
+
rubyzip
|
40
|
+
shoulda (2.11.3)
|
41
|
+
|
42
|
+
PLATFORMS
|
43
|
+
ruby
|
44
|
+
|
45
|
+
DEPENDENCIES
|
46
|
+
bundler (~> 1.0.0)
|
47
|
+
jeweler (~> 1.5.2)
|
48
|
+
parallel (>= 0.5.2)
|
49
|
+
sauce (>= 0.17.5)
|
50
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Agora Games
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= gondola
|
2
|
+
|
3
|
+
WORK IN PROGRESS
|
4
|
+
|
5
|
+
== Contributing to gondola
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Agora Games. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require './lib/gondola/version'
|
4
|
+
begin
|
5
|
+
Bundler.setup(:default, :development)
|
6
|
+
rescue Bundler::BundlerError => e
|
7
|
+
$stderr.puts e.message
|
8
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
9
|
+
exit e.status_code
|
10
|
+
end
|
11
|
+
require 'rake'
|
12
|
+
|
13
|
+
require 'jeweler'
|
14
|
+
Jeweler::Tasks.new do |gem|
|
15
|
+
gem.name = "gondola"
|
16
|
+
gem.homepage = "http://github.com/perrym5/gondola"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{Ruby command line utility and library for integrating the Selenium IDE more tightly with Sauce Labs' Ondemand services}
|
19
|
+
gem.description = %Q{
|
20
|
+
Gondola is Ruby command line utility and as well as a library which helps
|
21
|
+
for integrate the Selenium IDE more tightly with Sauce Labs' Ondemand services and
|
22
|
+
provide greater ease for those who would like to use both tools but do not have
|
23
|
+
enough technical knowledge
|
24
|
+
}
|
25
|
+
gem.email = "mperry@agoragames.com"
|
26
|
+
gem.authors = ["Matthew Perry"]
|
27
|
+
gem.version = Gondola::Version::STRING
|
28
|
+
# Dependencies in GemFile
|
29
|
+
end
|
30
|
+
Jeweler::RubygemsDotOrgTasks.new
|
31
|
+
|
32
|
+
require 'rake/testtask'
|
33
|
+
Rake::TestTask.new(:test) do |test|
|
34
|
+
test.libs << 'lib' << 'test'
|
35
|
+
test.pattern = 'test/**/test_*.rb'
|
36
|
+
test.verbose = true
|
37
|
+
end
|
38
|
+
|
39
|
+
begin
|
40
|
+
require 'rcov/rcovtask'
|
41
|
+
Rcov::RcovTask.new do |test|
|
42
|
+
test.libs << 'test'
|
43
|
+
test.pattern = 'test/**/test_*.rb'
|
44
|
+
test.verbose = true
|
45
|
+
end
|
46
|
+
rescue LoadError
|
47
|
+
task :rcov do
|
48
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
task :default => :test
|
53
|
+
|
54
|
+
require 'rake/rdoctask'
|
55
|
+
Rake::RDocTask.new do |rdoc|
|
56
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
57
|
+
|
58
|
+
rdoc.rdoc_dir = 'rdoc'
|
59
|
+
rdoc.title = "gondola #{version}"
|
60
|
+
rdoc.rdoc_files.include('README*')
|
61
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
62
|
+
end
|
data/bin/gondola
CHANGED
@@ -1,71 +1,68 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
# Gondola
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# DESCRIPTION:
|
7
|
-
# Main executable file which will dish out projects in parallel
|
8
|
-
# after converting them as needed
|
3
|
+
# Gondola - gondola
|
4
|
+
# Main executable file which will dish out projects in parallel
|
5
|
+
# after converting them as needed
|
9
6
|
|
10
7
|
require 'rubygems'
|
11
8
|
require 'yaml'
|
12
9
|
require 'cmdparse'
|
13
10
|
|
14
|
-
lib_dir = File.expand_path(
|
15
|
-
$LOAD_PATH.unshift(
|
11
|
+
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib/'))
|
12
|
+
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
|
16
13
|
|
17
14
|
require 'gondola'
|
18
15
|
|
19
16
|
# Command parsing stuff
|
20
|
-
cmd = CmdParse::CommandParser.new(
|
17
|
+
cmd = CmdParse::CommandParser.new(true, true)
|
21
18
|
cmd.program_name = "gondola"
|
22
|
-
cmd.program_version =
|
23
|
-
cmd.add_command(
|
24
|
-
cmd.add_command(
|
19
|
+
cmd.program_version = Gondola::Version::STRING
|
20
|
+
cmd.add_command(CmdParse::HelpCommand.new)
|
21
|
+
cmd.add_command(CmdParse::VersionCommand.new)
|
25
22
|
|
26
23
|
# Run command
|
27
24
|
class RunCommand < CmdParse::Command
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
25
|
+
def initialize
|
26
|
+
super('run', false)
|
27
|
+
@opts = {}
|
28
|
+
self.short_desc = "Run an entire test suite or one test case"
|
29
|
+
# User supplied options for running a suite
|
30
|
+
self.options = CmdParse::OptionParserWrapper.new do |opt|
|
31
|
+
opt.on('-s', '--super_parallel', 'Execute all test cases at once') do |sp|
|
32
|
+
@opts[:super_parallel] = true
|
33
|
+
end
|
34
|
+
opt.on('-r', '--recursive', 'Execute all sub suites') do |r|
|
35
|
+
@opts[:recursive] = true
|
36
|
+
end
|
37
|
+
opt.on('-l', '--legacy', 'Allow legacy Gondola suites') do |l|
|
38
|
+
@opts[:legacy] = true
|
39
|
+
end
|
44
40
|
end
|
41
|
+
end
|
45
42
|
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
# Proper usage format
|
44
|
+
def usage
|
45
|
+
"Usage: #{commandparser.program_name} run [options] [tests]"
|
46
|
+
end
|
47
|
+
|
48
|
+
# Function that is executed when a user issues a run command
|
49
|
+
def execute(args)
|
50
|
+
if args.length < 1
|
51
|
+
puts run.usage
|
52
|
+
exit 1
|
49
53
|
end
|
50
|
-
|
51
|
-
#
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
# Can either provide directory or file
|
59
|
-
if File.exists?( test )
|
60
|
-
runner = Gondola::TestRunner.new
|
61
|
-
runner.addTest( test )
|
62
|
-
runner.run( @opts )
|
63
|
-
else
|
64
|
-
puts "Could not find file \"#{test}\""
|
65
|
-
end
|
54
|
+
test = args[0]
|
55
|
+
# Can either provide directory or file
|
56
|
+
if File.exists?(test)
|
57
|
+
runner = Gondola::TestRunner.new
|
58
|
+
runner.add_test(test)
|
59
|
+
runner.run(@opts)
|
60
|
+
else
|
61
|
+
puts "Could not find file \"#{test}\""
|
66
62
|
end
|
63
|
+
end
|
67
64
|
end
|
68
|
-
cmd.add_command(
|
65
|
+
cmd.add_command(RunCommand.new)
|
69
66
|
|
70
67
|
cmd.parse
|
71
|
-
exit(
|
68
|
+
exit(0)
|
data/gondola.gemspec
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{gondola}
|
8
|
+
s.version = "1.1.3"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Matthew Perry"]
|
12
|
+
s.date = %q{2011-03-09}
|
13
|
+
s.default_executable = %q{gondola}
|
14
|
+
s.description = %q{
|
15
|
+
Gondola is Ruby command line utility and as well as a library which helps
|
16
|
+
for integrate the Selenium IDE more tightly with Sauce Labs' Ondemand services and
|
17
|
+
provide greater ease for those who would like to use both tools but do not have
|
18
|
+
enough technical knowledge
|
19
|
+
}
|
20
|
+
s.email = %q{mperry@agoragames.com}
|
21
|
+
s.executables = ["gondola"]
|
22
|
+
s.extra_rdoc_files = [
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.rdoc"
|
25
|
+
]
|
26
|
+
s.files = [
|
27
|
+
".document",
|
28
|
+
"Gemfile",
|
29
|
+
"Gemfile.lock",
|
30
|
+
"LICENSE.txt",
|
31
|
+
"README.rdoc",
|
32
|
+
"Rakefile",
|
33
|
+
"bin/gondola",
|
34
|
+
"examples/config.yml",
|
35
|
+
"examples/gondola_agora_fail.html",
|
36
|
+
"examples/gondola_agora_pass.html",
|
37
|
+
"gondola.gemspec",
|
38
|
+
"lib/gondola.rb",
|
39
|
+
"lib/gondola/converter.rb",
|
40
|
+
"lib/gondola/tester.rb",
|
41
|
+
"lib/gondola/testrunner.rb",
|
42
|
+
"lib/gondola/version.rb",
|
43
|
+
"test/helper.rb",
|
44
|
+
"test/test_gondola.rb"
|
45
|
+
]
|
46
|
+
s.homepage = %q{http://github.com/perrym5/gondola}
|
47
|
+
s.licenses = ["MIT"]
|
48
|
+
s.require_paths = ["lib"]
|
49
|
+
s.rubygems_version = %q{1.6.0}
|
50
|
+
s.summary = %q{Ruby command line utility and library for integrating the Selenium IDE more tightly with Sauce Labs' Ondemand services}
|
51
|
+
s.test_files = [
|
52
|
+
"test/helper.rb",
|
53
|
+
"test/test_gondola.rb"
|
54
|
+
]
|
55
|
+
|
56
|
+
if s.respond_to? :specification_version then
|
57
|
+
s.specification_version = 3
|
58
|
+
|
59
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
60
|
+
s.add_runtime_dependency(%q<sauce>, [">= 0.17.5"])
|
61
|
+
s.add_runtime_dependency(%q<parallel>, [">= 0.5.2"])
|
62
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
63
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
64
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
65
|
+
else
|
66
|
+
s.add_dependency(%q<sauce>, [">= 0.17.5"])
|
67
|
+
s.add_dependency(%q<parallel>, [">= 0.5.2"])
|
68
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
69
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
70
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
71
|
+
end
|
72
|
+
else
|
73
|
+
s.add_dependency(%q<sauce>, [">= 0.17.5"])
|
74
|
+
s.add_dependency(%q<parallel>, [">= 0.5.2"])
|
75
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
76
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
77
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
data/lib/gondola.rb
CHANGED
data/lib/gondola/converter.rb
CHANGED
@@ -1,216 +1,213 @@
|
|
1
|
-
# Gondola
|
2
|
-
# FILE: converter.rb
|
3
|
-
# AUTHOR: Matthew Perry
|
4
|
-
# DESCRIPTION:
|
1
|
+
# Gondola - converter.rb:
|
5
2
|
# Function definition for turning Selenium HTML into
|
6
3
|
# webdriver ruby code
|
7
4
|
|
8
5
|
module Gondola
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
class Converter
|
7
|
+
# Constructor that opens an HTML file
|
8
|
+
def initialize(filename, sel="@sel")
|
9
|
+
File.open(filename, "r") do |f|
|
10
|
+
@html = f.read
|
11
|
+
end
|
12
|
+
@s_obj = sel
|
13
|
+
ruby()
|
14
|
+
end
|
15
|
+
|
16
|
+
# Function: name
|
17
|
+
# Returns the name of this test case
|
18
|
+
def name
|
19
|
+
unless @name
|
20
|
+
@name = /<title>(.*)<\/title>/.match(@html)[1]
|
21
|
+
end
|
22
|
+
@name
|
23
|
+
end
|
24
|
+
|
25
|
+
# Function: ruby
|
26
|
+
# This function parses the selenium
|
27
|
+
# HTML file and sends commands to the
|
28
|
+
# html_to_ruby helper function
|
29
|
+
def ruby
|
30
|
+
unless @ruby
|
31
|
+
@ruby = ""
|
32
|
+
# Get body of commands from flattened html
|
33
|
+
cmd_body = /<tbody>(.*)<\/tbody>/.match(@html.split("\n").join(''))[1]
|
34
|
+
|
35
|
+
# Define some patterns for the individual commands
|
36
|
+
block_rxp = Regexp.new(/<tr>(.*?)<\/tr>/)
|
37
|
+
cmd_rxp = Regexp.new(/<td>(.*?)<\/td>\s*<td>(.*?)<\/td>\s*<td>(.*?)<\/td>/)
|
38
|
+
|
39
|
+
# Loop over all commands
|
40
|
+
cmd_body.scan(block_rxp ) do |cmd_block|
|
41
|
+
cmd_block[0].scan(cmd_rxp ) do |cmd|
|
42
|
+
# Need to make sure arguements are represented
|
43
|
+
# correctly
|
44
|
+
if cmd[1] =~ /\$\{(.*)\}/
|
45
|
+
cmd[1] = $1
|
46
|
+
elsif cmd[1] != ""
|
47
|
+
cmd[1] = cmd[1].inspect
|
14
48
|
end
|
15
|
-
|
16
|
-
|
49
|
+
if cmd[2] =~ /\$\{(.*)\}/
|
50
|
+
cmd[2] = $1
|
51
|
+
elsif cmd[2] != ""
|
52
|
+
cmd[2] = cmd[2].inspect
|
53
|
+
end
|
54
|
+
# Append commands to a result string
|
55
|
+
args = [ cmd[1], cmd[2] ]
|
56
|
+
@ruby << html_to_ruby(cmd[0], args)
|
57
|
+
@ruby << "\ncmd_inc\n"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
@ruby
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
# Function: html_to_ruby
|
66
|
+
# cmd - the name of the command
|
67
|
+
# args - array of arguements to cmd
|
68
|
+
# This function turns a command that has been
|
69
|
+
# extracted from a selenium HTML file into
|
70
|
+
# one that can be used by the ruby-driver for
|
71
|
+
# selenium
|
72
|
+
def html_to_ruby(cmd, args)
|
73
|
+
# Select over various command types
|
74
|
+
case cmd
|
75
|
+
# Assert command
|
76
|
+
when /^(assert|verify)(.*)$/ then
|
77
|
+
# Check to see if this is a negated assertion
|
78
|
+
tester = $1
|
79
|
+
string = $2
|
80
|
+
if $1 =~ /(.*)Not(.*)$/
|
81
|
+
string = $1 + $2
|
82
|
+
tester = tester + "_not"
|
17
83
|
end
|
18
84
|
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
85
|
+
# Check the semantics of the command
|
86
|
+
if semantic_is?(string)
|
87
|
+
retval = "#{tester} #{@s_obj}.is_#{underscore(string)}"
|
88
|
+
if args[0] != ""
|
89
|
+
retval += "(#{args[0]}"
|
90
|
+
end
|
91
|
+
if args[1] != ""
|
92
|
+
retval += ", #{args[1]}"
|
93
|
+
end
|
94
|
+
retval += ")"
|
95
|
+
else
|
96
|
+
var = args[0]
|
97
|
+
extra = ''
|
98
|
+
if args[1] != ""
|
99
|
+
var = args[1]
|
100
|
+
extra = "(#{args[0]})"
|
101
|
+
end
|
102
|
+
retval = "#{tester}_eq #{var}, #{@s_obj}.get_#{underscore(string)}" + extra
|
26
103
|
end
|
27
104
|
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
# htmltoruby helper function
|
32
|
-
def ruby
|
33
|
-
unless @ruby
|
34
|
-
@ruby = ""
|
35
|
-
# Get body of commands from flattened html
|
36
|
-
cmdBody = /<tbody>(.*)<\/tbody>/.match( @html.split("\n").join('') )[1]
|
37
|
-
|
38
|
-
# Define some patterns for the individual commands
|
39
|
-
blockRxp = Regexp.new( /<tr>(.*?)<\/tr>/ )
|
40
|
-
cmdRxp = Regexp.new( /<td>(.*?)<\/td>\s*<td>(.*?)<\/td>\s*<td>(.*?)<\/td>/ )
|
41
|
-
|
42
|
-
# Loop over all commands
|
43
|
-
cmdBody.scan( blockRxp ) do |cmdBlock|
|
44
|
-
cmdBlock[0].scan( cmdRxp ) do |cmd|
|
45
|
-
# Need to make sure arguements are represented
|
46
|
-
# correctly
|
47
|
-
if cmd[1] =~ /\$\{(.*)\}/
|
48
|
-
cmd[1] = $1
|
49
|
-
elsif cmd[1] != ""
|
50
|
-
cmd[1] = cmd[1].inspect
|
51
|
-
end
|
52
|
-
if cmd[2] =~ /\$\{(.*)\}/
|
53
|
-
cmd[2] = $1
|
54
|
-
elsif cmd[2] != ""
|
55
|
-
cmd[2] = cmd[2].inspect
|
56
|
-
end
|
57
|
-
# Append commands to a result string
|
58
|
-
args = [ cmd[1], cmd[2] ]
|
59
|
-
@ruby << htmltoruby( cmd[0], args )
|
60
|
-
@ruby << "\ncmdInc\n"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
@ruby
|
105
|
+
# All commands return arrays that need to be joined
|
106
|
+
if string =~ /^All/
|
107
|
+
retval += ".join(\",\")"
|
65
108
|
end
|
109
|
+
return retval
|
66
110
|
|
67
|
-
|
68
|
-
|
69
|
-
#
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
#
|
74
|
-
#
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
if $1 =~ /(.*)Not(.*)$/
|
84
|
-
string = $1 + $2
|
85
|
-
tester = tester + "Not"
|
86
|
-
end
|
87
|
-
|
88
|
-
# Check the symantics of the command
|
89
|
-
if commandIs( string )
|
90
|
-
retval = "#{tester} #{@sObject}.is_#{underscore(string)}"
|
91
|
-
if args[0] != ""
|
92
|
-
retval += "(#{args[0]}"
|
93
|
-
end
|
94
|
-
if args[1] != ""
|
95
|
-
retval += ", #{args[1]}"
|
96
|
-
end
|
97
|
-
retval += ")"
|
98
|
-
else
|
99
|
-
var = args[0]
|
100
|
-
extra = ''
|
101
|
-
if args[1] != ""
|
102
|
-
var = args[1]
|
103
|
-
extra = "(#{args[0]})"
|
104
|
-
end
|
105
|
-
retval = "#{tester}Eq #{var}, #{@sObject}.get_#{underscore(string)}" + extra
|
106
|
-
end
|
107
|
-
|
108
|
-
# All commands return arrays that need to be joined
|
109
|
-
if string =~ /^All/
|
110
|
-
retval += ".join(\",\")"
|
111
|
-
end
|
112
|
-
return retval
|
113
|
-
|
114
|
-
# Wait For command
|
115
|
-
when /^waitFor(.*)$/ then
|
116
|
-
# Special case
|
117
|
-
if $1 == "PageToLoad"
|
118
|
-
return "#{@sObject}.wait_for_page_to_load \"30000\""
|
119
|
-
end
|
120
|
-
# The expression that is checked against depends on whether
|
121
|
-
# or not the command uses the "is" or the "get" symantic
|
122
|
-
if commandIs( $1 )
|
123
|
-
expression = "#{@sObject}.is_#{underscore($1)}(#{args[0]}"
|
124
|
-
if args[1] != ""
|
125
|
-
expression += ", #{args[1]}"
|
126
|
-
end
|
127
|
-
expression += ")"
|
128
|
-
else
|
129
|
-
expression = "#{args[1]} == #{@sObject}.get_#{underscore($1)}(#{args[1]})"
|
130
|
-
end
|
131
|
-
# The waitFor commands loop until something is satisfied
|
132
|
-
return "assert !60.times{ break if(#{expression} rescue false); sleep 1 }"
|
133
|
-
|
134
|
-
# AndWait command POSTFIX
|
135
|
-
when /^(.*)AndWait$/ then
|
136
|
-
# A command with a postfix of AndWait simply adds
|
137
|
-
# a second command which waits a certain time
|
138
|
-
firstPart = htmltoruby( $1, args )
|
139
|
-
secondPart = "\n#{@sObject}.wait_for_page_to_load \"30000\""
|
140
|
-
return firstPart + secondPart
|
141
|
-
|
142
|
-
# store command
|
143
|
-
when /^store(.*)$/ then
|
144
|
-
string = $1
|
145
|
-
# Store by itself doesnt use any selenium functions
|
146
|
-
# its the same as a regular assignment
|
147
|
-
if $1 == ""
|
148
|
-
# Arguements have quotes by default
|
149
|
-
# they need to be stripped for LHS assignments
|
150
|
-
args[1] = args[1].match( /"(.*)"/ )[1]
|
151
|
-
return "#{args[1]} = #{args[0]}"
|
152
|
-
end
|
153
|
-
|
154
|
-
# Otherwise, a store command takes the result of the
|
155
|
-
# cmd and stores it somewhere
|
156
|
-
var = args[0]
|
157
|
-
extra = ""
|
158
|
-
if args[1] != ""
|
159
|
-
var = args[1]
|
160
|
-
extra = "( #{args[0]} )"
|
161
|
-
end
|
162
|
-
# Arguements have quotes by default
|
163
|
-
# they need to be stripped for LHS assignments
|
164
|
-
var = var.match( /"(.*)"/ )[1]
|
165
|
-
if commandIs( string )
|
166
|
-
return "#{var} = #{@sObject}.is_#{underscore(string)}" + extra
|
167
|
-
else
|
168
|
-
return "#{var} = #{@sObject}.get_#{underscore(string)}" + extra
|
169
|
-
end
|
170
|
-
|
171
|
-
# Pause is directly translated
|
172
|
-
when /^pause$/ then
|
173
|
-
convert = args[0].to_f * 0.001
|
174
|
-
return "sleep #{convert}"
|
175
|
-
|
176
|
-
# Default case
|
177
|
-
else
|
178
|
-
# Most commands just need to be converted to
|
179
|
-
# underscore_case and have their arguements
|
180
|
-
# appeneded
|
181
|
-
cmdNew = underscore( cmd )
|
182
|
-
add = ""
|
183
|
-
if args[1] != ""
|
184
|
-
add = ", #{args[1]}"
|
185
|
-
end
|
186
|
-
return "#{@sObject}.#{cmdNew} #{args[0]}" + add
|
187
|
-
end
|
111
|
+
# Wait For command
|
112
|
+
when /^waitFor(.*)$/ then
|
113
|
+
# Special case
|
114
|
+
if $1 == "PageToLoad"
|
115
|
+
return "#{@s_obj}.wait_for_page_to_load \"30000\""
|
116
|
+
end
|
117
|
+
# The expression that is checked against depends on whether
|
118
|
+
# or not the command uses the "is" or the "get" semantic
|
119
|
+
if semantic_is?($1)
|
120
|
+
expression = "#{@s_obj}.is_#{underscore($1)}(#{args[0]}"
|
121
|
+
if args[1] != ""
|
122
|
+
expression += ", #{args[1]}"
|
123
|
+
end
|
124
|
+
expression += ")"
|
125
|
+
else
|
126
|
+
expression = "#{args[1]} == #{@s_obj}.get_#{underscore($1)}(#{args[1]})"
|
188
127
|
end
|
128
|
+
# The waitFor commands loop until something is satisfied
|
129
|
+
return "assert !60.times{ break if(#{expression} rescue false); sleep 1 }"
|
189
130
|
|
190
|
-
#
|
191
|
-
|
192
|
-
|
131
|
+
# AndWait command POSTFIX
|
132
|
+
when /^(.*)AndWait$/ then
|
133
|
+
# A command with a postfix of AndWait simply adds
|
134
|
+
# a second command which waits a certain time
|
135
|
+
firstPart = html_to_ruby($1, args)
|
136
|
+
secondPart = "\n#{@s_obj}.wait_for_page_to_load \"30000\""
|
137
|
+
return firstPart + secondPart
|
138
|
+
|
139
|
+
# store command
|
140
|
+
when /^store(.*)$/ then
|
141
|
+
string = $1
|
142
|
+
# Store by itself doesnt use any selenium functions
|
143
|
+
# its the same as a regular assignment
|
144
|
+
if $1 == ""
|
145
|
+
# Arguements have quotes by default
|
146
|
+
# they need to be stripped for LHS assignments
|
147
|
+
args[1] = args[1].match(/"(.*)"/)[1]
|
148
|
+
return "#{args[1]} = #{args[0]}"
|
193
149
|
end
|
194
|
-
|
195
|
-
#
|
196
|
-
#
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
return true
|
203
|
-
when /Editable$/
|
204
|
-
return true
|
205
|
-
when /Ordered$/
|
206
|
-
return true
|
207
|
-
when /Selected$/
|
208
|
-
return true
|
209
|
-
when /Visible$/
|
210
|
-
return true
|
211
|
-
else
|
212
|
-
return false
|
213
|
-
end
|
150
|
+
|
151
|
+
# Otherwise, a store command takes the result of the
|
152
|
+
# cmd and stores it somewhere
|
153
|
+
var = args[0]
|
154
|
+
extra = ""
|
155
|
+
if args[1] != ""
|
156
|
+
var = args[1]
|
157
|
+
extra = "(#{args[0]})"
|
214
158
|
end
|
159
|
+
# Arguements have quotes by default
|
160
|
+
# they need to be stripped for LHS assignments
|
161
|
+
var = var.match(/"(.*)"/)[1]
|
162
|
+
if semantic_is?(string)
|
163
|
+
return "#{var} = #{@s_obj}.is_#{underscore(string)}" + extra
|
164
|
+
else
|
165
|
+
return "#{var} = #{@s_obj}.get_#{underscore(string)}" + extra
|
166
|
+
end
|
167
|
+
|
168
|
+
# Pause is directly translated
|
169
|
+
when /^pause$/ then
|
170
|
+
convert = args[0].to_f * 0.001
|
171
|
+
return "sleep #{convert}"
|
172
|
+
|
173
|
+
# Default case
|
174
|
+
else
|
175
|
+
# Most commands just need to be converted to
|
176
|
+
# underscore_case and have their arguements
|
177
|
+
# appeneded
|
178
|
+
cmd_new = underscore(cmd)
|
179
|
+
add = ""
|
180
|
+
if args[1] != ""
|
181
|
+
add = ", #{args[1]}"
|
182
|
+
end
|
183
|
+
return "#{@s_obj}.#{cmd_new} #{args[0]}" + add
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
# Function to turn CamelCase into underscore_case
|
188
|
+
def underscore(str)
|
189
|
+
str.gsub(/(.)([A-Z])/,'\1_\2').downcase
|
190
|
+
end
|
191
|
+
|
192
|
+
# Function to weed out 11 special functions that
|
193
|
+
# use an "is" semantic
|
194
|
+
def semantic_is?(str)
|
195
|
+
case str
|
196
|
+
when /Present$/
|
197
|
+
return true
|
198
|
+
when /Checked$/
|
199
|
+
return true
|
200
|
+
when /Editable$/
|
201
|
+
return true
|
202
|
+
when /Ordered$/
|
203
|
+
return true
|
204
|
+
when /Selected$/
|
205
|
+
return true
|
206
|
+
when /Visible$/
|
207
|
+
return true
|
208
|
+
else
|
209
|
+
return false
|
210
|
+
end
|
215
211
|
end
|
212
|
+
end
|
216
213
|
end
|