symbiont 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. data/Gemfile.lock +10 -39
  2. data/HISTORY.md +6 -0
  3. data/lib/symbiont.rb +8 -4
  4. data/lib/symbiont/enclosers.rb +4 -4
  5. data/lib/symbiont/evaluators.rb +22 -29
  6. data/lib/symbiont/generators.rb +82 -317
  7. data/lib/symbiont/platform_selenium.rb +18 -0
  8. data/lib/symbiont/platform_selenium/platform_object.rb +236 -0
  9. data/lib/symbiont/platform_selenium/web_objects/button.rb +13 -0
  10. data/lib/symbiont/platform_selenium/web_objects/checkbox.rb +21 -0
  11. data/lib/symbiont/platform_selenium/web_objects/common.rb +104 -0
  12. data/lib/symbiont/platform_selenium/web_objects/link.rb +13 -0
  13. data/lib/symbiont/platform_selenium/web_objects/radio.rb +21 -0
  14. data/lib/symbiont/platform_selenium/web_objects/select_list.rb +79 -0
  15. data/lib/symbiont/platform_selenium/web_objects/table.rb +40 -0
  16. data/lib/symbiont/platform_selenium/web_objects/table_row.rb +36 -0
  17. data/lib/symbiont/platform_selenium/web_objects/text_field.rb +14 -0
  18. data/lib/symbiont/platform_watir.rb +13 -4
  19. data/lib/symbiont/platform_watir/platform_object.rb +74 -262
  20. data/lib/symbiont/platform_watir/web_objects/checkbox.rb +21 -0
  21. data/lib/symbiont/platform_watir/web_objects/common.rb +82 -0
  22. data/lib/symbiont/platform_watir/web_objects/radio.rb +21 -0
  23. data/lib/symbiont/platform_watir/web_objects/select_list.rb +67 -0
  24. data/lib/symbiont/platform_watir/web_objects/table.rb +31 -0
  25. data/lib/symbiont/platform_watir/web_objects/table_row.rb +31 -0
  26. data/lib/symbiont/platform_watir/web_objects/text_field.rb +13 -0
  27. data/lib/symbiont/platforms.rb +18 -6
  28. data/lib/symbiont/version.rb +1 -1
  29. data/lib/symbiont/web_objects/_common.rb +53 -74
  30. data/lib/symbiont/web_objects/button.rb +23 -4
  31. data/lib/symbiont/web_objects/checkbox.rb +24 -10
  32. data/lib/symbiont/web_objects/div.rb +9 -1
  33. data/lib/symbiont/web_objects/link.rb +25 -4
  34. data/lib/symbiont/web_objects/paragraph.rb +11 -0
  35. data/lib/symbiont/web_objects/radio.rb +27 -1
  36. data/lib/symbiont/web_objects/select_list.rb +20 -56
  37. data/lib/symbiont/web_objects/span.rb +9 -1
  38. data/lib/symbiont/web_objects/table.rb +19 -22
  39. data/lib/symbiont/web_objects/table_cell.rb +17 -1
  40. data/lib/symbiont/web_objects/table_row.rb +18 -25
  41. data/lib/symbiont/web_objects/text_field.rb +27 -11
  42. data/symbiont.gemspec +3 -8
  43. metadata +29 -122
  44. data/app/Gemfile +0 -4
  45. data/app/app.rb +0 -181
  46. data/app/config/database.rb +0 -9
  47. data/app/models/plan.rb +0 -10
  48. data/app/models/product.rb +0 -10
  49. data/app/models/study.rb +0 -11
  50. data/app/models/user.rb +0 -13
  51. data/app/public/css/style.css +0 -138
  52. data/app/views/create_plan.erb +0 -21
  53. data/app/views/create_product.erb +0 -15
  54. data/app/views/create_study.erb +0 -24
  55. data/app/views/create_user.erb +0 -60
  56. data/app/views/db_plans.erb +0 -31
  57. data/app/views/db_products.erb +0 -29
  58. data/app/views/db_studies.erb +0 -33
  59. data/app/views/db_users.erb +0 -23
  60. data/app/views/entity_list.erb +0 -10
  61. data/app/views/index.erb +0 -8
  62. data/app/views/layout.erb +0 -39
  63. data/app/views/login_page.erb +0 -17
  64. data/app/views/success_1.erb +0 -2
  65. data/app/views/success_2.erb +0 -2
  66. data/app/views/test_database.erb +0 -13
  67. data/app/views/test_events.erb +0 -51
  68. data/app/views/test_login.erb +0 -53
  69. data/app/views/test_login_error.erb +0 -22
  70. data/app/views/test_login_success.erb +0 -22
  71. data/app/views/test_page.erb +0 -184
  72. data/specs/button.feature +0 -44
  73. data/specs/checkbox.feature +0 -40
  74. data/specs/data_setter.feature +0 -29
  75. data/specs/definitions/pages.rb +0 -156
  76. data/specs/div.feature +0 -11
  77. data/specs/evaluators.feature +0 -17
  78. data/specs/events.feature +0 -30
  79. data/specs/frame.feature +0 -5
  80. data/specs/link.feature +0 -42
  81. data/specs/locators.feature +0 -17
  82. data/specs/radio.feature +0 -38
  83. data/specs/select_list.feature +0 -50
  84. data/specs/simple_test.feature +0 -13
  85. data/specs/span.feature +0 -11
  86. data/specs/support/env.rb +0 -20
  87. data/specs/support/hooks.rb +0 -11
  88. data/specs/support/test_steps/action_steps_buttons.rb +0 -70
  89. data/specs/support/test_steps/action_steps_checkboxes.rb +0 -75
  90. data/specs/support/test_steps/action_steps_data_setter.rb +0 -56
  91. data/specs/support/test_steps/action_steps_divs.rb +0 -18
  92. data/specs/support/test_steps/action_steps_evaluators.rb +0 -15
  93. data/specs/support/test_steps/action_steps_events.rb +0 -77
  94. data/specs/support/test_steps/action_steps_frames.rb +0 -13
  95. data/specs/support/test_steps/action_steps_links.rb +0 -61
  96. data/specs/support/test_steps/action_steps_locators.rb +0 -44
  97. data/specs/support/test_steps/action_steps_navigate.rb +0 -25
  98. data/specs/support/test_steps/action_steps_radios.rb +0 -75
  99. data/specs/support/test_steps/action_steps_select_lists.rb +0 -106
  100. data/specs/support/test_steps/action_steps_spans.rb +0 -18
  101. data/specs/support/test_steps/action_steps_tables.rb +0 -82
  102. data/specs/support/test_steps/action_steps_text_fields.rb +0 -107
  103. data/specs/support/test_steps/action_steps_webobjects.rb +0 -31
  104. data/specs/support/test_steps/simple_test_steps.rb +0 -8
  105. data/specs/table.feature +0 -39
  106. data/specs/text_field.feature +0 -47
  107. data/specs/web_object.feature +0 -15
@@ -2,15 +2,34 @@ module Symbiont
2
2
  module WebObjects
3
3
 
4
4
  class Button < WebObject
5
-
6
- def self.usable_selectors
7
- super + [:value, :text, :css]
5
+
6
+ def initialize(web_object, platform)
7
+ @web_object = web_object
8
+ include_platform_specifics_for(platform)
9
+ end
10
+
11
+ def self.usable_selectors_for_watir
12
+ super + [:value, :text, :src, :alt, :css]
13
+ end
14
+
15
+ def self.usable_selectors_for_selenium
16
+ super + [:value, :src, :alt]
17
+ end
18
+
19
+ def include_platform_specifics_for(platform)
20
+ super
21
+ if platform[:platform] == :selenium_webdriver
22
+ require 'symbiont/platform_selenium/web_objects/button'
23
+ self.class.send :include, Symbiont::Platforms::SeleniumWebDriver::Button
24
+ end
8
25
  end
9
-
26
+
10
27
  end # class: Button
11
28
 
12
29
  ::Symbiont::WebObjects.class_for_type[:submit] = ::Symbiont::WebObjects::Button
13
30
  ::Symbiont::WebObjects.class_for_type[:button] = ::Symbiont::WebObjects::Button
31
+ ::Symbiont::WebObjects.class_for_type[:image] = ::Symbiont::WebObjects::Button
32
+ ::Symbiont::WebObjects.class_for_type[:reset] = ::Symbiont::WebObjects::Button
14
33
 
15
34
  end # module: WebObjects
16
35
  end # module: Symbiont
@@ -2,19 +2,33 @@ module Symbiont
2
2
  module WebObjects
3
3
 
4
4
  class CheckBox < WebObject
5
-
6
- def check
7
- @web_object.set
5
+
6
+ def initialize(web_object, platform)
7
+ @web_object = web_object
8
+ include_platform_specifics_for(platform)
9
+ end
10
+
11
+ def self.usable_selectors_for_watir
12
+ super + [:value]
8
13
  end
9
-
10
- def uncheck
11
- @web_object.clear
14
+
15
+ def self.usable_selectors_for_selenium
16
+ super + [:value]
12
17
  end
13
-
14
- def checked?
15
- @web_object.set?
18
+
19
+ def include_platform_specifics_for(platform)
20
+ super
21
+ if platform[:platform] == :watir_webdriver
22
+ require 'symbiont/platform_watir/web_objects/checkbox'
23
+ self.class.send :include, Symbiont::Platforms::WatirWebDriver::CheckBox
24
+ elsif platform[:platform] == :selenium_webdriver
25
+ require 'symbiont/platform_selenium/web_objects/checkbox'
26
+ self.class.send :include, Symbiont::Platforms::SeleniumWebDriver::CheckBox
27
+ else
28
+ raise ArgumentError, "The platform #{platform[:platform]} appears to be unsupported."
29
+ end
16
30
  end
17
-
31
+
18
32
  end # class: CheckBox
19
33
 
20
34
  ::Symbiont::WebObjects.class_for_type[:checkbox] = ::Symbiont::WebObjects::CheckBox
@@ -2,7 +2,15 @@ module Symbiont
2
2
  module WebObjects
3
3
 
4
4
  class Div < WebObject
5
-
5
+
6
+ def self.usable_selectors_for_watir
7
+ super + [:text, :title]
8
+ end
9
+
10
+ def self.usable_selectors_for_selenium
11
+ super + [:text, :title]
12
+ end
13
+
6
14
  end # class: Div
7
15
 
8
16
  ::Symbiont::WebObjects.class_for_tag[:div] = ::Symbiont::WebObjects::Div
@@ -2,15 +2,36 @@ module Symbiont
2
2
  module WebObjects
3
3
 
4
4
  class Link < WebObject
5
-
6
- def self.usable_selectors
5
+
6
+ def initialize(web_object, platform)
7
+ @web_object = web_object
8
+ include_platform_specifics_for(platform)
9
+ end
10
+
11
+ def self.usable_selectors_for_watir
7
12
  super + [:href, :text, :title, :css]
8
13
  end
9
14
 
10
- def self.selector_mapping
15
+ def self.selector_mapping_for_watir
11
16
  super.merge({:link => :text, :link_text => :text})
12
17
  end
13
-
18
+
19
+ def self.usable_selectors_for_selenium
20
+ super + [:link, :link_text, :title]
21
+ end
22
+
23
+ def self.selector_mapping_for_selenium
24
+ super.merge(:text => :link_text)
25
+ end
26
+
27
+ def include_platform_specifics_for(platform)
28
+ super
29
+ if platform[:platform] == :selenium_webdriver
30
+ require 'symbiont/platform_selenium/web_objects/link'
31
+ self.class.send :include, Symbiont::Platforms::SeleniumWebDriver::Link
32
+ end
33
+ end
34
+
14
35
  end # class: Link
15
36
 
16
37
  ::Symbiont::WebObjects.class_for_tag[:a] = ::Symbiont::WebObjects::Link
@@ -0,0 +1,11 @@
1
+ module Symbiont
2
+ module WebObjects
3
+
4
+ class Paragraph < WebObject
5
+
6
+ end # class: Paragraph
7
+
8
+ ::Symbiont::WebObjects.class_for_tag[:p] = ::Symbiont::WebObjects::Paragraph
9
+
10
+ end # module: WebObjects
11
+ end # module: Symbiont
@@ -2,7 +2,33 @@ module Symbiont
2
2
  module WebObjects
3
3
 
4
4
  class Radio < WebObject
5
-
5
+
6
+ def initialize(web_object, platform)
7
+ @web_object = web_object
8
+ include_platform_specifics_for(platform)
9
+ end
10
+
11
+ def self.usable_selectors_for_watir
12
+ super + [:value]
13
+ end
14
+
15
+ def self.usable_selectors_for_selenium
16
+ super + [:value]
17
+ end
18
+
19
+ def include_platform_specifics_for(platform)
20
+ super
21
+ if platform[:platform] == :watir_webdriver
22
+ require 'symbiont/platform_watir/web_objects/radio'
23
+ self.class.send :include, Symbiont::Platforms::WatirWebDriver::Radio
24
+ elsif platform[:platform] == :selenium_webdriver
25
+ require 'symbiont/platform_selenium/web_objects/radio'
26
+ self.class.send :include, Symbiont::Platforms::SeleniumWebDriver::Radio
27
+ else
28
+ raise ArgumentError, "The platform #{platform[:platform]} appears to be unsupported."
29
+ end
30
+ end
31
+
6
32
  end # class: Radio
7
33
 
8
34
  ::Symbiont::WebObjects.class_for_type[:radio] = ::Symbiont::WebObjects::Radio
@@ -2,69 +2,33 @@ module Symbiont
2
2
  module WebObjects
3
3
 
4
4
  class SelectList < WebObject
5
- # This method is used to return an Option object based on the index provided.
6
- # @return [Symbiont::WebObjects::Option]
7
- def [](idx)
8
- Object::Symbiont::WebObjects::Option.new(options[idx])
5
+ def initialize(web_object, platform)
6
+ @web_object = web_object
7
+ include_platform_specifics_for(platform)
9
8
  end
10
-
11
- # This method returns an array of Option objects that are contained within
12
- # a select list object.
13
- # @return [array of Symbiont::WebObjects::Option]
14
- def options
15
- web_objects = []
16
- options = @web_object.wd.find_elements(:xpath, option_xpath)
17
- options.each do |opt|
18
- web_objects << Object::Symbiont::WebObjects::Option.new(opt)
19
- end
20
- web_objects
9
+
10
+ def self.usable_selectors_for_watir
11
+ super + [:value, :text]
21
12
  end
22
-
23
- # Selects an option from the select list.
24
- def select(value)
25
- @web_object.select(value)
26
- end
27
-
28
- # Selects the option whose value attribute matches the provided string.
29
- def select_value(value)
30
- @web_object.select_value(value)
31
- end
32
-
33
- # This method returns an array of strings that contain the text of the
34
- # currently selected options in a select list.
35
- # @return [Array<String>]
36
- def selected_options
37
- @web_object.selected_options.map { |e| e.text }.compact
38
- end
39
-
40
- # This method returns an array of strings that contain the values of the
41
- # currently selected options in a select list.
42
- # @return [Array<String>]
43
- def selected_values
44
- @web_object.selected_options.map { |e| e.value }.compact
45
- end
46
-
47
- # This method returns true if any of the text or the lable of any option
48
- # that is selected matches the provided value.
49
- # @param [String, Regexp] value A value to check for
50
- # @return [Boolean]
51
- def selected?(value)
52
- @web_object.selected? value
53
- end
54
-
55
- # This method checks to see if the select list has one or more options
56
- # where the text or the label matches the provided value.
57
- # @param [String, Regexp] value A value to check for.
58
- # @return [Boolean]
59
- def include?(value)
60
- @web_object.include? value
61
- end
62
-
13
+
63
14
  protected
64
15
 
65
16
  def option_xpath
66
17
  ".//child::option"
67
18
  end
19
+
20
+ def include_platform_specifics_for(platform)
21
+ super
22
+ if platform[:platform] == :watir_webdriver
23
+ require 'symbiont/platform_watir/web_objects/select_list'
24
+ self.class.send :include, Symbiont::Platforms::WatirWebDriver::SelectList
25
+ elsif platform[:platform] == :selenium_webdriver
26
+ require 'symbiont/platform_selenium/web_objects/select_list'
27
+ self.class.send :include, Symbiont::Platforms::SeleniumWebDriver::SelectList
28
+ else
29
+ raise ArgumentError, "The platform #{platform[:platform]} appears to be unsupported."
30
+ end
31
+ end
68
32
  end # class: SelectList
69
33
 
70
34
  ::Symbiont::WebObjects.class_for_tag[:select] = ::Symbiont::WebObjects::SelectList
@@ -2,7 +2,15 @@ module Symbiont
2
2
  module WebObjects
3
3
 
4
4
  class Span < WebObject
5
-
5
+
6
+ def self.usable_selectors_for_watir
7
+ super + [:text, :title]
8
+ end
9
+
10
+ def self.usable_selectors_for_selenium
11
+ super + [:text, :title]
12
+ end
13
+
6
14
  end # class: Span
7
15
 
8
16
  ::Symbiont::WebObjects.class_for_tag[:span] = ::Symbiont::WebObjects::Span
@@ -3,17 +3,12 @@ module Symbiont
3
3
 
4
4
  class Table < WebObject
5
5
  include Enumerable
6
-
7
- # This method is used to return a TableRow object based on the index provided. When
8
- # the index provided is a string, the text will be matched with the text from the first
9
- # column.
10
- # @return [Symbiont::WebObjects::TableRow]
11
- def [](index)
12
- index = find_by_title(index) if index.kind_of?(String)
13
- return nil unless index
14
- Object::Symbiont::WebObjects::TableRow.new(@web_object[index])
6
+
7
+ def initialize(web_object, platform)
8
+ @web_object = web_object
9
+ include_platform_specifics_for(platform)
15
10
  end
16
-
11
+
17
12
  # This method is an iterator that returns a TableRow object each time through
18
13
  # the loop.
19
14
  # @return [Symbiont::WebObjects::TableRow]
@@ -22,12 +17,7 @@ module Symbiont
22
17
  yield self[index - 1]
23
18
  end
24
19
  end
25
-
26
- # This method will return the number of rows in a table.
27
- def rows
28
- @web_object.wd.find_elements(:xpath, row_xpath).size
29
- end
30
-
20
+
31
21
  # Returns a reference to the first row web object of a table.
32
22
  # @return [Symbiont::WebObjects::TableRow]
33
23
  def first_row
@@ -45,13 +35,20 @@ module Symbiont
45
35
  def row_xpath
46
36
  ".//child::tr"
47
37
  end
48
-
49
- private
50
-
51
- def find_by_title(row_text)
52
- @web_object.rows.find_index {|row| row[0].text == row_text}
38
+
39
+ def include_platform_specifics_for(platform)
40
+ super
41
+ if platform[:platform] == :watir_webdriver
42
+ require 'symbiont/platform_watir/web_objects/table'
43
+ self.class.send :include, Symbiont::Platforms::WatirWebDriver::Table
44
+ elsif platform[:platform] == :selenium_webdriver
45
+ require 'symbiont/platform_selenium/web_objects/table'
46
+ self.class.send :include, Symbiont::Platforms::SeleniumWebDriver::Table
47
+ else
48
+ raise ArgumentError, "The platform #{platform[:platform]} appears to be unsupported."
49
+ end
53
50
  end
54
-
51
+
55
52
  end # class: Table
56
53
 
57
54
  ::Symbiont::WebObjects.class_for_tag[:table] = ::Symbiont::WebObjects::Table
@@ -2,7 +2,23 @@ module Symbiont
2
2
  module WebObjects
3
3
 
4
4
  class TableCell < WebObject
5
-
5
+
6
+ def initialize(web_object, platform)
7
+ @web_object = web_object
8
+ end
9
+
10
+ def enabled?
11
+ true
12
+ end
13
+
14
+ def self.usable_selectors_for_watir
15
+ super + [:text]
16
+ end
17
+
18
+ def self.usable_selectors_for_selenium
19
+ super + [:text]
20
+ end
21
+
6
22
  end # class: TableCell
7
23
 
8
24
  ::Symbiont::WebObjects.class_for_tag[:td] = ::Symbiont::WebObjects::TableCell
@@ -3,17 +3,12 @@ module Symbiont
3
3
 
4
4
  class TableRow < WebObject
5
5
  include Enumerable
6
-
7
- # This method is used to return a TableCell object based on the index provided. When
8
- # the index provided is a string, the text will be matched with the text from the
9
- # columns in the first row.
10
- # @return [Symbiont::WebObjects::TableCell]
11
- def [](index)
12
- index = find_by_title(index) if index.kind_of?(String)
13
- return nil unless index
14
- Object::Symbiont::WebObjects::TableCell.new(@web_object[index])
6
+
7
+ def initialize(web_object, platform)
8
+ @web_object = web_object
9
+ include_platform_specifics_for(platform)
15
10
  end
16
-
11
+
17
12
  # This method is an iterator that returns a TableCell object each time through
18
13
  # the loop.
19
14
  # @return [Symbiont::WebObjects::TableCell]
@@ -22,27 +17,25 @@ module Symbiont
22
17
  yield self[index - 1]
23
18
  end
24
19
  end
25
-
26
- # This method returns the number of columns in a table object.
27
- def columns
28
- @web_object.wd.find_elements(:xpath, cell_xpath).size
29
- end
30
-
20
+
31
21
  protected
32
22
 
33
23
  def cell_xpath
34
24
  ".//child::td|th"
35
25
  end
36
-
37
- private
38
-
39
- def find_by_title(column_text)
40
- table = @web_object.parent
41
- table = table.parent if table.tag_name == 'tbody'
42
- first_row = table[0]
43
- first_row.cells.find_index {|column| column.text.include? column_text}
26
+
27
+ def include_platform_specifics_for(platform)
28
+ super
29
+ if platform[:platform] == :watir_webdriver
30
+ require 'symbiont/platform_watir/web_objects/table_row'
31
+ self.class.send :include, Symbiont::Platforms::WatirWebDriver::TableRow
32
+ elsif platform[:platform] == :selenium_webdriver
33
+ require 'symbiont/platform_selenium/web_objects/table_row'
34
+ self.class.send :include, Symbiont::Platforms::SeleniumWebDriver::TableRow
35
+ else
36
+ raise ArgumentError, "The platform #{platform[:platform]} appears to be unsupported."
37
+ end
44
38
  end
45
-
46
39
  end # class: TableRow
47
40
 
48
41
  ::Symbiont::WebObjects.class_for_tag[:tr] = ::Symbiont::WebObjects::TableRow