symbiont 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/Gemfile.lock +22 -7
  2. data/HISTORY.md +6 -0
  3. data/app/public/css/site.css +16 -0
  4. data/app/public/js/site.js +3 -1
  5. data/app/views/comics.erb +23 -1
  6. data/app/views/webobject.erb +1 -1
  7. data/lib/symbiont/data_setter.rb +7 -3
  8. data/lib/symbiont/enclosers.rb +24 -27
  9. data/lib/symbiont/evaluators.rb +52 -23
  10. data/lib/symbiont/factory.rb +19 -75
  11. data/lib/symbiont/generators.rb +172 -44
  12. data/lib/symbiont/platform_watir/platform_object.rb +202 -18
  13. data/lib/symbiont/version.rb +1 -1
  14. data/lib/symbiont/web_objects/button.rb +1 -1
  15. data/lib/symbiont/web_objects/checkbox.rb +1 -1
  16. data/lib/symbiont/web_objects/heading.rb +12 -0
  17. data/lib/symbiont/web_objects/hidden_field.rb +19 -0
  18. data/lib/symbiont/web_objects/label.rb +15 -0
  19. data/lib/symbiont/web_objects/list_item.rb +13 -0
  20. data/lib/symbiont/web_objects/ordered_list.rb +49 -0
  21. data/lib/symbiont/web_objects/radio.rb +1 -1
  22. data/lib/symbiont/web_objects/select_list.rb +1 -1
  23. data/lib/symbiont/web_objects/table.rb +4 -0
  24. data/lib/symbiont/web_objects/table_row.rb +4 -0
  25. data/lib/symbiont/web_objects/text_area.rb +26 -0
  26. data/lib/symbiont/web_objects/unordered_list.rb +49 -0
  27. data/lib/symbiont.rb +7 -0
  28. data/lucid.yml +6 -0
  29. data/spec/spec_helper.rb +70 -16
  30. data/spec/symbiont/data_setter_spec.rb +65 -62
  31. data/spec/symbiont/enclosers_spec.rb +76 -57
  32. data/spec/symbiont/evaluators_spec.rb +95 -75
  33. data/spec/symbiont/factory_spec.rb +174 -122
  34. data/spec/symbiont/generators/button_generators_spec.rb +34 -31
  35. data/spec/symbiont/generators/checkbox_generators_spec.rb +79 -75
  36. data/spec/symbiont/generators/div_generators_spec.rb +56 -52
  37. data/spec/symbiont/generators/hidden_field_generators_spec.rb +65 -0
  38. data/spec/symbiont/generators/link_generators_spec.rb +30 -27
  39. data/spec/symbiont/generators/paragraph_generators_spec.rb +22 -17
  40. data/spec/symbiont/generators/radio_generators_spec.rb +76 -77
  41. data/spec/symbiont/generators/select_list_generators_spec.rb +93 -77
  42. data/spec/symbiont/generators/span_generators_spec.rb +56 -52
  43. data/spec/symbiont/generators/{cell_generators_spec.rb → table_cell_generators_spec.rb} +56 -52
  44. data/spec/symbiont/generators/table_generators_spec.rb +56 -52
  45. data/spec/symbiont/generators/text_area_generators_spec.rb +72 -0
  46. data/spec/symbiont/generators/text_field_generators_spec.rb +30 -27
  47. data/spec/symbiont/generators_spec.rb +38 -28
  48. data/spec/symbiont/locators_spec.rb +68 -68
  49. data/spec/symbiont/platform_object_spec.rb +2 -4
  50. data/spec/symbiont/symbiont_spec.rb +10 -8
  51. data/spec/symbiont/web_object_spec.rb +194 -194
  52. data/spec/symbiont/web_objects/button_spec.rb +38 -30
  53. data/spec/symbiont/web_objects/checkbox_spec.rb +27 -27
  54. data/spec/symbiont/web_objects/div_spec.rb +18 -11
  55. data/spec/symbiont/web_objects/heading_spec.rb +22 -0
  56. data/spec/symbiont/web_objects/hidden_field_spec.rb +18 -0
  57. data/spec/symbiont/web_objects/label_spec.rb +18 -0
  58. data/spec/symbiont/web_objects/link_spec.rb +33 -33
  59. data/spec/symbiont/web_objects/list_item_spec.rb +18 -0
  60. data/spec/symbiont/web_objects/option_spec.rb +9 -9
  61. data/spec/symbiont/web_objects/ordered_list_spec.rb +53 -0
  62. data/spec/symbiont/web_objects/paragraph_spec.rb +9 -2
  63. data/spec/symbiont/web_objects/radio_spec.rb +27 -27
  64. data/spec/symbiont/web_objects/select_list_spec.rb +69 -69
  65. data/spec/symbiont/web_objects/span_spec.rb +18 -11
  66. data/spec/symbiont/web_objects/table_cell_spec.rb +19 -19
  67. data/spec/symbiont/web_objects/table_row_spec.rb +58 -58
  68. data/spec/symbiont/web_objects/table_spec.rb +61 -61
  69. data/spec/symbiont/web_objects/text_area_spec.rb +18 -0
  70. data/spec/symbiont/web_objects/text_field_spec.rb +39 -39
  71. data/spec/symbiont/web_objects/unordered_list_spec.rb +51 -0
  72. data/specs/common/support/browser.rb +25 -0
  73. data/specs/common/support/env.rb +6 -0
  74. data/specs/common/support/events.rb +15 -0
  75. data/specs/enclosers.feature +9 -0
  76. data/specs/evaluators.feature +26 -0
  77. data/specs/pages/characters.rb +22 -0
  78. data/specs/pages/home.rb +9 -0
  79. data/specs/pages/stardate.rb +23 -0
  80. data/specs/pages/web_objects.rb +77 -0
  81. data/specs/select_list.feature +53 -0
  82. data/specs/steps/enclosers_steps.rb +17 -0
  83. data/specs/steps/evaluators_steps.rb +44 -0
  84. data/specs/steps/navigation_steps.rb +14 -0
  85. data/specs/steps/select_list_steps.rb +94 -0
  86. data/specs/steps/table_cell_steps.rb +31 -0
  87. data/specs/steps/table_steps.rb +87 -0
  88. data/specs/table.feature +49 -0
  89. data/specs/table_cell.feature +27 -0
  90. data/symbiont.gemspec +4 -1
  91. metadata +72 -6
  92. data/cucumber.yml +0 -6
@@ -20,7 +20,7 @@ module Symbiont
20
20
  end
21
21
 
22
22
  def self.usable_selectors
23
- super + [:value]
23
+ super + [:value, :label]
24
24
  end
25
25
 
26
26
  end # class: CheckBox
@@ -0,0 +1,12 @@
1
+ module Symbiont
2
+ module WebObjects
3
+
4
+ class Heading < WebObject
5
+
6
+ end # class: Heading
7
+
8
+ ::Symbiont::WebObjects.class_for_tag[:h1] = ::Symbiont::WebObjects::Heading
9
+ ::Symbiont::WebObjects.class_for_tag[:h2] = ::Symbiont::WebObjects::Heading
10
+
11
+ end # module: WebObjects
12
+ end # module: Symbiont
@@ -0,0 +1,19 @@
1
+ module Symbiont
2
+ module WebObjects
3
+
4
+ class HiddenField < WebObject
5
+
6
+ def initialize(web_object)
7
+ @web_object = web_object
8
+ end
9
+
10
+ def self.usable_selectors
11
+ super + [:text, :value]
12
+ end
13
+
14
+ end # class: HiddenField
15
+
16
+ ::Symbiont::WebObjects.class_for_tag[:hidden] = ::Symbiont::WebObjects::HiddenField
17
+
18
+ end # module: WebObjects
19
+ end # module: Symbiont
@@ -0,0 +1,15 @@
1
+ module Symbiont
2
+ module WebObjects
3
+
4
+ class Label < WebObject
5
+
6
+ def self.usable_selectors
7
+ super + [:text]
8
+ end
9
+
10
+ end # class: Label
11
+
12
+ ::Symbiont::WebObjects.class_for_tag[:label] = ::Symbiont::WebObjects::Label
13
+
14
+ end # module: WebObjects
15
+ end # module: Symbiont
@@ -0,0 +1,13 @@
1
+ module Symbiont
2
+ module WebObjects
3
+
4
+ class ListItem < WebObject
5
+ def self.usable_selectors
6
+ super + [:text]
7
+ end
8
+ end
9
+
10
+ ::Symbiont::WebObjects.class_for_tag[:li] = ::Symbiont::WebObjects::ListItem
11
+
12
+ end # module: WebObjects
13
+ end # module: Symbiont
@@ -0,0 +1,49 @@
1
+ module Symbiont
2
+ module WebObjects
3
+
4
+ class OrderedList < WebObject
5
+ include Enumerable
6
+
7
+ def initialize(web_object)
8
+ @web_object = web_object
9
+ end
10
+
11
+ # @return [Symbiont::WebObjects::ListItem]
12
+ def [](index)
13
+ ::Symbiont::WebObjects::ListItem.new(children[index])
14
+ end
15
+
16
+ # Return the number of list items contained in the ordered list.
17
+ def items
18
+ children.size
19
+ end
20
+
21
+ # @return [Symbiont::WebObjects::ListItem]
22
+ def each
23
+ for index in 1..self.items do
24
+ yield self[index - 1]
25
+ end
26
+ end
27
+
28
+ protected
29
+
30
+ def list_item_xpath
31
+ ".//child::li"
32
+ end
33
+
34
+ private
35
+
36
+ def children
37
+ list_items.find_all { |item| item.parent == web_object }
38
+ end
39
+
40
+ def list_items
41
+ web_object.ols(:xpath => list_item_xpath)
42
+ end
43
+
44
+ end # class: OrderedList
45
+
46
+ ::Symbiont::WebObjects.class_for_tag[:ol] = ::Symbiont::WebObjects::OrderedList
47
+
48
+ end # module: WebObjects
49
+ end # module: Symbiont
@@ -8,7 +8,7 @@ module Symbiont
8
8
  end
9
9
 
10
10
  def self.usable_selectors
11
- super + [:value]
11
+ super + [:value, :label]
12
12
  end
13
13
 
14
14
  def select
@@ -7,7 +7,7 @@ module Symbiont
7
7
  end
8
8
 
9
9
  def self.usable_selectors
10
- super + [:value, :text]
10
+ super + [:value, :text, :label]
11
11
  end
12
12
 
13
13
  # This method is used to return an Option object based on the index provided.
@@ -50,6 +50,10 @@ module Symbiont
50
50
  ".//child::tr"
51
51
  end
52
52
 
53
+ def initialize_row(element)
54
+ ::Symbiont::WebObjects::TableRow.new(element)
55
+ end
56
+
53
57
  private
54
58
 
55
59
  def find_by_title(row_text)
@@ -38,6 +38,10 @@ module Symbiont
38
38
  ".//child::td|th"
39
39
  end
40
40
 
41
+ def initialize_cell(element)
42
+ ::Symbiont::WebObjects::TableCell.new(element)
43
+ end
44
+
41
45
  private
42
46
 
43
47
  def find_by_title(column_text)
@@ -0,0 +1,26 @@
1
+ module Symbiont
2
+ module WebObjects
3
+
4
+ class TextArea < WebObject
5
+ def initialize(web_object)
6
+ @web_object = web_object
7
+ end
8
+
9
+ def value=(value)
10
+ web_object.set value
11
+ end
12
+
13
+ def clear
14
+ web_object.wd.clear
15
+ end
16
+
17
+ def self.usable_selectors
18
+ super + [:title, :value, :text, :label]
19
+ end
20
+
21
+ end # class: TextArea
22
+
23
+ ::Symbiont::WebObjects.class_for_tag[:textarea] = ::Symbiont::WebObjects::TextArea
24
+
25
+ end # module: WebObjects
26
+ end # module: Symbiont
@@ -0,0 +1,49 @@
1
+ module Symbiont
2
+ module WebObjects
3
+
4
+ class UnorderedList < WebObject
5
+ include Enumerable
6
+
7
+ def initialize(web_object)
8
+ @web_object = web_object
9
+ end
10
+
11
+ # @return [Symbiont::WebObjects::ListItem]
12
+ def [](index)
13
+ ::Symbiont::WebObjects::ListItem.new(children[index])
14
+ end
15
+
16
+ # Return the number of list items contained in the ordered list.
17
+ def items
18
+ children.size
19
+ end
20
+
21
+ # @return [Symbiont::WebObjects::ListItem]
22
+ def each
23
+ for index in 1..self.items do
24
+ yield self[index - 1]
25
+ end
26
+ end
27
+
28
+ protected
29
+
30
+ def list_item_xpath
31
+ ".//child::li"
32
+ end
33
+
34
+ private
35
+
36
+ def children
37
+ list_items.find_all { |item| item.parent == web_object }
38
+ end
39
+
40
+ def list_items
41
+ web_object.uls(:xpath => list_item_xpath)
42
+ end
43
+
44
+ end # class: UnorderedList
45
+
46
+ ::Symbiont::WebObjects.class_for_tag[:ul] = ::Symbiont::WebObjects::UnorderedList
47
+
48
+ end # module: WebObjects
49
+ end # module: Symbiont
data/lib/symbiont.rb CHANGED
@@ -82,4 +82,11 @@ module Symbiont
82
82
  @platform = get_platform_for(browser)
83
83
  end
84
84
 
85
+ # This method processes a block with single or multiple parameters.
86
+ #
87
+ # @param [Proc] block the block to process
88
+ def process_block(&block)
89
+ block.arity == 1 ? block.call(self) : self.instance_eval(&block)
90
+ end
91
+
85
92
  end
data/lucid.yml ADDED
@@ -0,0 +1,6 @@
1
+ options: BROWSER=firefox --no-source --format pretty
2
+ spec_path: specs
3
+ step_path: specs\steps
4
+ requires:
5
+ - specs\common
6
+ - specs\pages
data/spec/spec_helper.rb CHANGED
@@ -14,25 +14,79 @@ require 'symbiont'
14
14
  class DefinitionTest
15
15
  include Symbiont
16
16
 
17
- url_is "http://localhost:4567"
18
- begin_at "http://localhost:4567"
19
-
20
- title_is "Title of Page"
21
- look_for :testPage
22
-
23
- link :reset_password, id: "resetPassword"
24
- button :submit, id: "btnSubmit"
25
- text_field :login_name, id: "loginName"
17
+ url_is "http://localhost:9292"
18
+ begin_at "http://localhost:9292"
19
+ title_is "Symbiote"
20
+
21
+ look_for :name
22
+
23
+ text_field :name, id: "name"
24
+ text_field :email do |element|
25
+ "email"
26
+ end
27
+
28
+ text_area :summary, id: "summary"
29
+ text_area :description do |element|
30
+ "description"
31
+ end
32
+
33
+ hidden_field :ssn, id: "ssn"
34
+ hidden_field :visa do |element|
35
+ "visa"
36
+ end
37
+
38
+ paragraph :first, id: "first"
39
+ p :last, id: "last"
40
+ paragraph :middle do |element|
41
+ "middle"
42
+ end
43
+
44
+ link :welcome, id: "welcome"
45
+ link :greetings do |element|
46
+ "greetings"
47
+ end
48
+
49
+ button :login, id: "login"
50
+ button :logout do |element|
51
+ "logout"
52
+ end
53
+
54
+ checkbox :apply_tax, id: "apply_tax"
55
+ checkbox :apply_fee do |element|
56
+ "apply_fee"
57
+ end
58
+
26
59
  select_list :concepts, id: "concepts"
27
- checkbox :apply_tax, id: "applyTax"
28
- radio :include_tax, id: "includeTax"
29
- table :accounts, id: "accounts"
30
- cell :totalValue, id: "totalValue"
31
- paragraph :intro, id: "intro"
60
+ select_list :topics do |element|
61
+ "topics"
62
+ end
63
+
64
+ radio :include_tax, id: "include_tax"
65
+ radio :include_fee do |element|
66
+ "include_fee"
67
+ end
68
+
32
69
  div :section, id: "section"
70
+ div :aside do |element|
71
+ "aside"
72
+ end
73
+
33
74
  span :inline, id: "inline"
34
-
35
- within_frame(id: "frame") do |frame|
75
+ span :part do |element|
76
+ "part"
77
+ end
78
+
79
+ table :accounts, id: "accounts"
80
+ table :invoices do |element|
81
+ "invoices"
82
+ end
83
+
84
+ cell :total, id: "total"
85
+ cell :sum do |element|
86
+ "sum"
87
+ end
88
+
89
+ frame(id: "frame") do |frame|
36
90
  text_field :framedLoginName, id: "framedLoginName", frame: frame
37
91
  end
38
92
  end
@@ -1,62 +1,65 @@
1
- require 'spec_helper'
2
-
3
- describe Symbiont::DataSetter do
4
- let(:watir_browser) { mock_browser_for_watir }
5
- let(:watir_definition) { DefinitionTest.new(watir_browser) }
6
-
7
- it "should set data in a text field" do
8
- watir_definition.should_receive(:login_name=).with('jnyman')
9
- watir_definition.should_receive(:object_enabled_for).and_return(true)
10
- watir_definition.using('login_name' => 'jnyman')
11
- end
12
-
13
- it "should not set data in a non-existent text field" do
14
- watir_browser.should_not_receive(:text_field)
15
- watir_definition.using('fake_field' => 'fake data')
16
- end
17
-
18
- it "should not set data in a disabled text field" do
19
- watir_definition.should_not_receive(:login_name=)
20
- watir_definition.should_receive(:login_name_object).and_return(watir_browser)
21
- watir_browser.should_receive(:enabled?).and_return(false)
22
- watir_definition.using('login_name' => 'test data')
23
- end
24
-
25
- it "should set data in a select list field" do
26
- watir_definition.should_receive(:concepts=).with('physics')
27
- watir_definition.should_receive(:object_enabled_for).and_return(true)
28
- watir_definition.using('concepts' => 'physics')
29
- end
30
-
31
- it "should check a checkbox field" do
32
- watir_definition.should_receive(:check_apply_tax)
33
- watir_definition.should_receive(:object_enabled_for).and_return(true)
34
- watir_definition.using('apply_tax' => true)
35
- end
36
-
37
- it "should uncheck a checkbox field" do
38
- watir_definition.should_receive(:uncheck_apply_tax)
39
- watir_definition.should_receive(:object_enabled_for).and_return(true)
40
- watir_definition.using('apply_tax' => false)
41
- end
42
-
43
- it "should not check data in a disabled checkbox field" do
44
- watir_definition.should_not_receive(:check_apply_tax)
45
- watir_definition.should_receive(:apply_tax_object).and_return(watir_browser)
46
- watir_browser.should_receive(:enabled?).and_return(false)
47
- watir_definition.using('apply_tax' => true)
48
- end
49
-
50
- it "should select a radio field" do
51
- watir_definition.should_receive(:select_include_tax)
52
- watir_definition.should_receive(:object_enabled_for).and_return(true)
53
- watir_definition.using('include_tax' => true)
54
- end
55
-
56
- it "should not select data in a disable radio field" do
57
- watir_definition.should_not_receive(:select_include_tax)
58
- watir_definition.should_receive(:include_tax_object).and_return(watir_browser)
59
- watir_browser.should_receive(:enabled?).and_return(false)
60
- watir_definition.using('include_tax' => true)
61
- end
62
- end
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::DataSetter do
4
+ let(:watir_browser) { mock_browser_for_watir }
5
+ let(:watir_definition) { DefinitionTest.new(watir_browser) }
6
+
7
+ it "should set data in a text field" do
8
+ watir_definition.should_receive(:name=).with('jnyman')
9
+ watir_definition.should_receive(:object_enabled_for).and_return(true)
10
+ watir_definition.using('name' => 'jnyman')
11
+ end
12
+
13
+ it "should not set data in a non-existent text field" do
14
+ watir_browser.should_not_receive(:text_field)
15
+ watir_definition.using('fake_field' => 'fake data')
16
+ end
17
+
18
+ it "should not set data in a disabled text field" do
19
+ watir_definition.should_not_receive(:name=)
20
+ watir_definition.should_receive(:name_object).twice.and_return(watir_browser)
21
+ watir_browser.should_receive(:enabled?).and_return(false)
22
+ watir_browser.should_receive(:tag_name).with(no_args)
23
+ watir_definition.using('name' => 'test data')
24
+ end
25
+
26
+ it "should set data in a select list field" do
27
+ watir_definition.should_receive(:concepts=).with('physics')
28
+ watir_definition.should_receive(:object_enabled_for).and_return(true)
29
+ watir_definition.using('concepts' => 'physics')
30
+ end
31
+
32
+ it "should check a checkbox field" do
33
+ watir_definition.should_receive(:check_apply_tax)
34
+ watir_definition.should_receive(:object_enabled_for).and_return(true)
35
+ watir_definition.using('apply_tax' => true)
36
+ end
37
+
38
+ it "should uncheck a checkbox field" do
39
+ watir_definition.should_receive(:uncheck_apply_tax)
40
+ watir_definition.should_receive(:object_enabled_for).and_return(true)
41
+ watir_definition.using('apply_tax' => false)
42
+ end
43
+
44
+ it "should not check data in a disabled checkbox field" do
45
+ watir_definition.should_not_receive(:check_apply_tax)
46
+ watir_definition.should_receive(:apply_tax_object).twice.and_return(watir_browser)
47
+ watir_browser.should_receive(:enabled?).and_return(false)
48
+ watir_browser.should_receive(:tag_name).with(no_args)
49
+ watir_definition.using('apply_tax' => true)
50
+ end
51
+
52
+ it "should select a radio field" do
53
+ watir_definition.should_receive(:select_include_tax)
54
+ watir_definition.should_receive(:object_enabled_for).and_return(true)
55
+ watir_definition.using('include_tax' => true)
56
+ end
57
+
58
+ it "should not select data in a disable radio field" do
59
+ watir_definition.should_not_receive(:select_include_tax)
60
+ watir_definition.should_receive(:include_tax_object).twice.and_return(watir_browser)
61
+ watir_browser.should_receive(:enabled?).and_return(false)
62
+ watir_browser.should_receive(:tag_name).with(no_args)
63
+ watir_definition.using('include_tax' => true)
64
+ end
65
+ end
@@ -1,57 +1,76 @@
1
- require 'spec_helper'
2
-
3
- describe Symbiont::Enclosers do
4
- let(:watir_browser) { mock_browser_for_watir }
5
- let(:watir_definition) { DefinitionTest.new(watir_browser) }
6
-
7
- context "a definition using watir-webdriver" do
8
- it "should allow frames to act as a context" do
9
- watir_browser.should_receive(:frame).with(id: "frame").and_return(watir_browser)
10
- watir_browser.should_receive(:text_field).and_return(watir_browser)
11
- watir_browser.should_receive(:wd).and_return(watir_browser)
12
- watir_browser.should_receive(:switch_to).and_return(watir_browser)
13
- watir_browser.should_receive(:default_content).and_return(watir_browser)
14
- web_object = watir_definition.framedLoginName_text_field
15
- web_object.should_not be_nil
16
- web_object.should be_instance_of Symbiont::WebObjects::TextField
17
- end
18
-
19
- it "should wait for a condition to be true" do
20
- watir_browser.should_receive(:wait_until).with(5, "some condition")
21
- watir_definition.wait_for(5, "some condition")
22
- end
23
-
24
- it "should handle alert message boxes" do
25
- watir_browser.should_receive(:wd).twice.and_return(watir_browser)
26
- watir_browser.should_receive(:execute_script).twice
27
- watir_definition.will_alert do
28
- end
29
- end
30
-
31
- it "should handle confirmation message boxes" do
32
- watir_browser.should_receive(:wd).twice.and_return(watir_browser)
33
- watir_browser.should_receive(:execute_script).twice
34
- watir_definition.will_confirm(true) do
35
- end
36
- end
37
-
38
- it "should handle prompt message boxes" do
39
- watir_browser.should_receive(:wd).twice.and_return(watir_browser)
40
- watir_browser.should_receive(:execute_script).twice
41
- watir_definition.will_prompt("Question") do
42
- end
43
- end
44
-
45
- it "attaches to a window by using the title" do
46
- watir_browser.should_receive(:window).with(:title => /Display\ Results/).and_return(watir_browser)
47
- watir_browser.should_receive(:use)
48
- watir_definition.within_window(title: "Display Results")
49
- end
50
-
51
- it "attaches to a window by using the url" do
52
- watir_browser.should_receive(:window).with(:url => /results\.html/).and_return(watir_browser)
53
- watir_browser.should_receive(:use)
54
- watir_definition.within_window(url: "results.html")
55
- end
56
- end
57
- end
1
+ require "spec_helper"
2
+
3
+ describe Symbiont::Enclosers do
4
+ let(:watir_browser) { mock_browser_for_watir }
5
+ let(:watir_definition) { DefinitionTest.new(watir_browser) }
6
+
7
+ context "a definition using watir-webdriver" do
8
+ it "should wait for a condition to be true" do
9
+ watir_browser.should_receive(:wait_until).with(5, "some condition")
10
+ watir_definition.wait_for(5, "some condition")
11
+ end
12
+
13
+ it "should wait for a condition to be true with any page level timeout" do
14
+ Symbiont.page_level_wait = 30
15
+ watir_browser.should_receive(:wait_until).with(30, nil)
16
+ watir_definition.wait_for
17
+ end
18
+
19
+ it "should be able to attach to a window by using the title" do
20
+ watir_browser.should_receive(:window).with(:title => /Display\ Results/).and_return(watir_browser)
21
+ watir_browser.should_receive(:use)
22
+ watir_definition.within_window(title: "Display Results")
23
+ end
24
+
25
+ it "should be able to attach to a window by using the url" do
26
+ watir_browser.should_receive(:window).with(:url => /results\.html/).and_return(watir_browser)
27
+ watir_browser.should_receive(:use)
28
+ watir_definition.within_window(url: "results.html")
29
+ end
30
+
31
+ it "should allow frames to act as a context" do
32
+ watir_browser.should_receive(:frame).with(id: "frame").and_return(watir_browser)
33
+ watir_browser.should_receive(:text_field).and_return(watir_browser)
34
+ watir_browser.should_receive(:wd).and_return(watir_browser)
35
+ watir_browser.should_receive(:switch_to).and_return(watir_browser)
36
+ watir_browser.should_receive(:default_content).and_return(watir_browser)
37
+ web_object = watir_definition.framedLoginName_text_field
38
+ web_object.should_not be_nil
39
+ web_object.should be_instance_of Symbiont::WebObjects::TextField
40
+ end
41
+
42
+ it "should be able to convert a modal popup to a window" do
43
+ watir_browser.should_receive(:execute_script)
44
+ watir_definition.within_modal {}
45
+ end
46
+
47
+ it "should handle alert message boxes" do
48
+ #watir_browser.should_receive(:wd).twice.and_return(watir_browser)
49
+ #watir_browser.should_receive(:execute_script).twice
50
+ watir_browser.should_receive(:alert).exactly(3).times.and_return(watir_browser)
51
+ watir_browser.should_receive(:exists?).and_return(true)
52
+ watir_browser.should_receive(:text)
53
+ watir_browser.should_receive(:ok)
54
+ watir_definition.will_alert do
55
+ end
56
+ end
57
+
58
+ it "should handle confirmation message boxes" do
59
+ #watir_browser.should_receive(:wd).twice.and_return(watir_browser)
60
+ #watir_browser.should_receive(:execute_script).twice
61
+ watir_browser.should_receive(:alert).exactly(3).times.and_return(watir_browser)
62
+ watir_browser.should_receive(:exists?).and_return(true)
63
+ watir_browser.should_receive(:text)
64
+ watir_browser.should_receive(:ok)
65
+ watir_definition.will_confirm(true) do
66
+ end
67
+ end
68
+
69
+ it "should handle prompt message boxes" do
70
+ watir_browser.should_receive(:wd).twice.and_return(watir_browser)
71
+ watir_browser.should_receive(:execute_script).twice
72
+ watir_definition.will_prompt("Question") do
73
+ end
74
+ end
75
+ end
76
+ end