symbiont 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/Gemfile.lock +6 -4
  2. data/HISTORY.md +8 -0
  3. data/Rakefile +8 -1
  4. data/app/views/test_page.erb +6 -1
  5. data/lib/symbiont/data_setter.rb +49 -0
  6. data/lib/symbiont/enclosers.rb +34 -0
  7. data/lib/symbiont/evaluators.rb +39 -1
  8. data/lib/symbiont/platform_watir/platform_object.rb +40 -0
  9. data/lib/symbiont/platforms.rb +3 -0
  10. data/lib/symbiont/version.rb +1 -1
  11. data/lib/symbiont/web_objects/_common.rb +4 -0
  12. data/lib/symbiont/web_objects/button.rb +4 -2
  13. data/lib/symbiont/web_objects/checkbox.rb +3 -1
  14. data/lib/symbiont/web_objects/div.rb +2 -0
  15. data/lib/symbiont/web_objects/link.rb +4 -2
  16. data/lib/symbiont/web_objects/radio.rb +2 -0
  17. data/lib/symbiont/web_objects/select_list.rb +2 -0
  18. data/lib/symbiont/web_objects/span.rb +2 -0
  19. data/lib/symbiont/web_objects/table.rb +2 -0
  20. data/lib/symbiont/web_objects/table_cell.rb +3 -0
  21. data/lib/symbiont/web_objects/table_row.rb +2 -0
  22. data/lib/symbiont/web_objects/text_field.rb +18 -3
  23. data/lib/symbiont/web_objects.rb +22 -0
  24. data/lib/symbiont.rb +2 -0
  25. data/spec/symbiont/data_setter_spec.rb +62 -0
  26. data/spec/symbiont/evaluators_spec.rb +35 -0
  27. data/spec/symbiont/web_object_spec.rb +5 -0
  28. data/spec/symbiont/web_objects/button_spec.rb +15 -0
  29. data/spec/symbiont/web_objects/checkbox_spec.rb +11 -0
  30. data/spec/symbiont/web_objects/div_spec.rb +11 -0
  31. data/spec/symbiont/web_objects/link_spec.rb +11 -0
  32. data/spec/symbiont/web_objects/radio_spec.rb +11 -0
  33. data/spec/symbiont/web_objects/select_list_spec.rb +11 -0
  34. data/spec/symbiont/web_objects/span_spec.rb +11 -0
  35. data/spec/symbiont/web_objects/table_cell_spec.rb +13 -0
  36. data/spec/symbiont/web_objects/table_row_spec.rb +4 -0
  37. data/spec/symbiont/web_objects/table_spec.rb +4 -0
  38. data/spec/symbiont/web_objects/text_field_spec.rb +31 -0
  39. data/specs/data_setter.feature +29 -0
  40. data/specs/definitions/pages.rb +23 -0
  41. data/specs/evaluators.feature +12 -0
  42. data/specs/link.feature +5 -1
  43. data/specs/support/test_steps/action_steps_data_setter.rb +56 -0
  44. data/specs/support/test_steps/action_steps_evaluators.rb +12 -0
  45. data/specs/support/test_steps/action_steps_links.rb +14 -0
  46. data/specs/support/test_steps/action_steps_navigate.rb +8 -2
  47. data/specs/support/test_steps/action_steps_text_fields.rb +40 -1
  48. data/specs/support/test_steps/action_steps_webobjects.rb +8 -2
  49. data/specs/text_field.feature +10 -0
  50. data/specs/web_object.feature +4 -0
  51. data/symbiont.gemspec +2 -1
  52. metadata +34 -4
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- symbiont (0.1.0)
5
- watir-webdriver (= 0.5.8)
4
+ symbiont (0.1.2)
5
+ watir-webdriver (= 0.6.1)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
@@ -24,7 +24,7 @@ GEM
24
24
  diff-lcs (~> 1.1.3)
25
25
  rspec-mocks (2.10.1)
26
26
  rubyzip (0.9.8)
27
- selenium-webdriver (2.21.2)
27
+ selenium-webdriver (2.22.1)
28
28
  childprocess (>= 0.2.5)
29
29
  ffi (~> 1.0)
30
30
  libwebsocket (~> 0.1.3)
@@ -34,8 +34,9 @@ GEM
34
34
  multi_json (~> 1.0)
35
35
  simplecov-html (~> 0.5.3)
36
36
  simplecov-html (0.5.3)
37
- watir-webdriver (0.5.8)
37
+ watir-webdriver (0.6.1)
38
38
  selenium-webdriver (>= 2.18.0)
39
+ yard (0.8.2.1)
39
40
 
40
41
  PLATFORMS
41
42
  x86-mingw32
@@ -44,3 +45,4 @@ DEPENDENCIES
44
45
  rspec (= 2.10.0)
45
46
  simplecov (= 0.6.4)
46
47
  symbiont!
48
+ yard (= 0.8.2.1)
data/HISTORY.md CHANGED
@@ -1,6 +1,14 @@
1
1
  Change Log and History
2
2
  ======================
3
3
 
4
+ Version 0.1.3 / 2012-07-15
5
+ --------------------------
6
+
7
+ This release introduces a lot of low-hanging fruit. For example there is now the ability to get the title, markup and the active URL of a page. There is also the ability to get a screenshot. It is also possible to get the tag name from a web object. As far as web objects, the ability to get and set values for text fields is now in place. I've also added the ability to execute specific JavaScript calls against the browser. This helps determine what web object currently has focus, as just one example.
8
+
9
+ A DataSetter module has been added to allow for easier population of data elements. The idea here is that a using method -- called against a page or activity definition -- can send data directly to web objects on that definition. This is just the start of a streamlined approach for populating data a bit easier than was previously the case. I have also made sure to update to the latest watir-webdriver.
10
+
11
+
4
12
  Version 0.1.2 / 2012-06-06
5
13
  --------------------------
6
14
 
data/Rakefile CHANGED
@@ -1,15 +1,22 @@
1
1
  #!/usr/bin/env rake
2
2
  require 'bundler/gem_tasks'
3
3
  require 'rspec/core/rake_task'
4
+ require 'yard'
4
5
 
5
6
  RSpec::Core::RakeTask.new do |c|
6
- options = ["--color"]
7
+ options = ["--color"]
7
8
  options += ["--format", "documentation"]
8
9
  options += ["--format", "nested", "--out output/rspec-report.txt"]
9
10
  options += ["--format", "html", "--out output/rspec-report.html"]
10
11
  c.rspec_opts = options
11
12
  end
12
13
 
14
+ desc "Generate API documentation"
15
+ YARD::Rake::YardocTask.new do |t|
16
+ t.files = ['lib/**/*.rb']
17
+ t.options = ['--title', 'Symbiont']
18
+ end
19
+
13
20
  namespace :spec do
14
21
  desc "Get code coverage for spec execution"
15
22
  RSpec::Core::RakeTask.new('cov') do |c|
@@ -41,6 +41,11 @@
41
41
  <br/>
42
42
  <input id="bookTitleID" class="bookTitleClass" name="bookTitleName" size="40" type="text">
43
43
  <br/>
44
+ <br />
45
+ <label id="book_author"><strong>Book Author:</strong></label>
46
+ <br />
47
+ <input id="bookAuthorID" size="40" type="text">
48
+ <br />
44
49
  <br/>
45
50
  <label id=book_summary"><strong>Book Summary:</strong></label>
46
51
  <br/>
@@ -163,7 +168,7 @@
163
168
 
164
169
  <div class="group">
165
170
  <div id="divTextID" name="divTextName" class="divTextClass">This text is within a div tag.</div>
166
- <span id="spanTextID" name="spanTextName" class="spanTextClass">This text is within a span tag.</div>
171
+ <span id="spanTextID" name="spanTextName" class="spanTextClass">This text is within a span tag.</span>
167
172
  </div>
168
173
 
169
174
  </section>
@@ -0,0 +1,49 @@
1
+ module Symbiont
2
+ module DataSetter
3
+
4
+ def using(data)
5
+ data.each do |key, value|
6
+ use_text_data_with(key, value) if text_settable_for(key) and object_enabled_for(key)
7
+ use_check_data_with(key, value) if value_checkable_for(key) and object_enabled_for(key)
8
+ use_select_data_with(key, value) if value_selectable_for(key) and object_enabled_for(key)
9
+ end
10
+ end
11
+
12
+ alias :using_data :using
13
+ alias :using_values :using
14
+ alias :use_data :using
15
+ alias :use_values :using
16
+
17
+ private
18
+
19
+ def use_text_data_with(key, value)
20
+ self.send "#{key}=", value
21
+ end
22
+
23
+ def use_check_data_with(key, value)
24
+ return self.send "check_#{key}" if value
25
+ return self.send "uncheck_#{key}"
26
+ end
27
+
28
+ def use_select_data_with(key, value)
29
+ return self.send "select_#{key}" if value
30
+ end
31
+
32
+ def text_settable_for(key)
33
+ respond_to?("#{key}=".to_sym)
34
+ end
35
+
36
+ def value_checkable_for(key)
37
+ respond_to?("check_#{key}".to_sym)
38
+ end
39
+
40
+ def value_selectable_for(key)
41
+ respond_to?("select_#{key}".to_sym)
42
+ end
43
+
44
+ def object_enabled_for(key)
45
+ self.send("#{key}_object").enabled?
46
+ end
47
+
48
+ end # module: DataSetter
49
+ end # module: Symbiont
@@ -39,14 +39,48 @@ module Symbiont
39
39
  @platform.wait_for(timeout, message, &block)
40
40
  end
41
41
 
42
+ # Provides a context for an action that will generate a JavaScript alert
43
+ # message box. The alert invocation will be overridden by the platform.
44
+ #
45
+ # @param [Proc] block the code that generates the alert
46
+ # @return [String] the message contained in the alert message box
47
+ #
48
+ # @example
49
+ # response = @page.will_alert do
50
+ # @page.submitForm
51
+ # end
42
52
  def will_alert(&block)
43
53
  @platform.will_alert(&block)
44
54
  end
45
55
 
56
+ # Provides a context for an action that will generate a JavaScript
57
+ # confirmation message box. The confirmation invocation will be
58
+ # overridden by the platform.
59
+ #
60
+ # @param [bool] true to accept the confirmation, false to cancel it
61
+ # @param [Proc] block the code that generates the confirmation
62
+ # @return [String] the message contained in the confirmation message box
63
+ #
64
+ # @example
65
+ # response = @page.will_confirm(true) do
66
+ # @page.areYouSure
67
+ # end
46
68
  def will_confirm(response, &block)
47
69
  @platform.will_confirm(response, &block)
48
70
  end
49
71
 
72
+ # Provides a context for an action that will generate a JavaScript prompt
73
+ # message box. The prompt invocation will be overridden by the platform.
74
+ #
75
+ # @param [String] response the value to be used in the prompt
76
+ # @param [Proc] block the code that generates the prompt
77
+ # @return [Hash] :message for the prompt message, :default_value for
78
+ # the value that the prompt had before the response was applied
79
+ #
80
+ # @example
81
+ # response = @page.will_prompt("use this") do
82
+ # @page.useValue
83
+ # end
50
84
  def will_prompt(response, &block)
51
85
  @platform.will_prompt(response, &block)
52
86
  end
@@ -8,10 +8,48 @@ module Symbiont
8
8
  @platform.visit(url)
9
9
  end
10
10
 
11
- # Returns the text of the current page.
11
+ # Returns the text of the current page. This is the text minus any
12
+ # markup.
12
13
  def text
13
14
  @platform.text
14
15
  end
15
16
 
17
+ # Returns the markup of the current page.
18
+ def markup
19
+ @platform.markup
20
+ end
21
+
22
+ alias :html :markup
23
+
24
+ # Returns the title of the current page.
25
+ def title
26
+ @platform.title
27
+ end
28
+
29
+ # Returns the URL of the active page.
30
+ def url
31
+ @platform.url
32
+ end
33
+
34
+ # Save a snapshot of the current screen to a provided file location.
35
+ # The file will be saved as a PNG file in the path specified or in the
36
+ # location where the tests are being run from.
37
+ # @param [String] file the file name to save the image as
38
+ def screenshot(file)
39
+ @platform.screenshot file
40
+ end
41
+
42
+ # Returns the web object that currently has focus.
43
+ def focus
44
+ @platform.focus
45
+ end
46
+
47
+ # Executes JavaScript against the browser instance.
48
+ def run_script(script)
49
+ @platform.run_script(script)
50
+ end
51
+
52
+ alias :execute_script :run_script
53
+
16
54
  end # module: Evaluators
17
55
  end # module: Symbiont
@@ -16,6 +16,24 @@ module Symbiont
16
16
  @browser.goto(url)
17
17
  end
18
18
 
19
+ # Platform method to get the URL of the active page.
20
+ # See Symbiont#url
21
+ def url
22
+ @browser.url
23
+ end
24
+
25
+ # Platform method to save the current screenshot to a file.
26
+ # See Symbiont#screenshot
27
+ def screenshot(file)
28
+ @browser.wd.save_screenshot(file)
29
+ end
30
+
31
+ # Platform method to run a script against the browser.
32
+ # See Symbiont#run_script
33
+ def run_script(script)
34
+ @browser.execute_script(script)
35
+ end
36
+
19
37
  ## Page-Level Actions ##
20
38
 
21
39
  # Platform method to retrieve text from the current page.
@@ -24,6 +42,27 @@ module Symbiont
24
42
  @browser.text
25
43
  end
26
44
 
45
+ # Platform method to retrieve markup from the current page.
46
+ # See Symbiont#markup
47
+ def markup
48
+ @browser.html
49
+ end
50
+
51
+ # Platform method to get the title of the current page.
52
+ # See Symbiont#title
53
+ def title
54
+ @browser.title
55
+ end
56
+
57
+ # Platform method to get the web object that has focus.
58
+ # See Symbiont#focus
59
+ def focus
60
+ web_object = @browser.execute_script("return document.activeElement")
61
+ type = web_object.type.to_sym if web_object.tag_name.to_sym == :input
62
+ object_class = ::Symbiont::WebObjects.get_class_for(web_object.tag_name, type)
63
+ object_class.new(web_object)
64
+ end
65
+
27
66
  ## Encloser Methods ##
28
67
 
29
68
  # Platform method to wait for an action to complete in a given time.
@@ -433,4 +472,5 @@ module Symbiont
433
472
  end # module: Platforms
434
473
  end # module: Symbiont
435
474
 
475
+ require 'symbiont/web_objects'
436
476
  Dir["#{File.dirname(__FILE__)}/../web_objects/**/*.rb"].sort.each { |file| require file }
@@ -6,6 +6,9 @@ module Symbiont
6
6
  # This module determines what execution platform Symbiont will use.
7
7
  # The decision is based on the browser that has been established for
8
8
  # the execution profile.
9
+ #
10
+ # @param [Object] browser the browser to establish the platform for
11
+ # @returns [Object] a platform object to execute tests against
9
12
  def get_platform_for(browser)
10
13
  if browser.is_a?(Watir::Browser)
11
14
  return @platform = Symbiont::Platforms::WatirWebDriver::PlatformObject.new(@browser)
@@ -1,3 +1,3 @@
1
1
  module Symbiont
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -43,6 +43,10 @@ module Symbiont
43
43
  @web_object.style(property)
44
44
  end
45
45
 
46
+ def tag
47
+ @web_object.tag_name
48
+ end
49
+
46
50
  def when_actionable(timeout=5)
47
51
  @web_object.wait_until_present(timeout)
48
52
  self
@@ -4,6 +4,8 @@ module Symbiont
4
4
  class Button < WebObject
5
5
 
6
6
  end # class: Button
7
-
7
+
8
+ ::Symbiont::WebObjects.class_for_type[:submit] = ::Symbiont::WebObjects::Button
9
+ ::Symbiont::WebObjects.class_for_type[:button] = ::Symbiont::WebObjects::Button
8
10
  end # module: WebObjects
9
- end # module: Symbiont
11
+ end # module: Symbiont
@@ -4,6 +4,8 @@ module Symbiont
4
4
  class CheckBox < WebObject
5
5
 
6
6
  end # class: CheckBox
7
-
7
+
8
+ ::Symbiont::WebObjects.class_for_type[:checkbox] = ::Symbiont::WebObjects::CheckBox
9
+
8
10
  end # module: WebObjects
9
11
  end # module: Symbiont
@@ -5,5 +5,7 @@ module Symbiont
5
5
 
6
6
  end # class: Div
7
7
 
8
+ ::Symbiont::WebObjects.class_for_tag[:div] = ::Symbiont::WebObjects::Div
9
+
8
10
  end # module: WebObjects
9
11
  end # module: Symbiont
@@ -4,6 +4,8 @@ module Symbiont
4
4
  class Link < WebObject
5
5
 
6
6
  end # class: Link
7
-
7
+
8
+ ::Symbiont::WebObjects.class_for_tag[:a] = ::Symbiont::WebObjects::Link
9
+
8
10
  end # module: WebObjects
9
- end # module: Symbiont
11
+ end # module: Symbiont
@@ -5,5 +5,7 @@ module Symbiont
5
5
 
6
6
  end # class: Radio
7
7
 
8
+ ::Symbiont::WebObjects.class_for_type[:radio] = ::Symbiont::WebObjects::Radio
9
+
8
10
  end # module: WebObjects
9
11
  end # module: Symbiont
@@ -5,5 +5,7 @@ module Symbiont
5
5
 
6
6
  end # class: SelectList
7
7
 
8
+ ::Symbiont::WebObjects.class_for_tag[:select] = ::Symbiont::WebObjects::SelectList
9
+
8
10
  end # module: WebObjects
9
11
  end # module: Symbiont
@@ -5,5 +5,7 @@ module Symbiont
5
5
 
6
6
  end # class: Span
7
7
 
8
+ ::Symbiont::WebObjects.class_for_tag[:span] = ::Symbiont::WebObjects::Span
9
+
8
10
  end # module: WebObjects
9
11
  end # module: Symbiont
@@ -53,5 +53,7 @@ module Symbiont
53
53
 
54
54
  end # class: Table
55
55
 
56
+ ::Symbiont::WebObjects.class_for_tag[:table] = ::Symbiont::WebObjects::Table
57
+
56
58
  end # module: WebObjects
57
59
  end # module: Symbiont
@@ -5,5 +5,8 @@ module Symbiont
5
5
 
6
6
  end # class: TableCell
7
7
 
8
+ ::Symbiont::WebObjects.class_for_tag[:td] = ::Symbiont::WebObjects::TableCell
9
+ ::Symbiont::WebObjects.class_for_tag[:th] = ::Symbiont::WebObjects::TableCell
10
+
8
11
  end # module: WebObjects
9
12
  end # module: Symbiont
@@ -43,5 +43,7 @@ module Symbiont
43
43
 
44
44
  end # class: TableRow
45
45
 
46
+ ::Symbiont::WebObjects.class_for_tag[:tr] = ::Symbiont::WebObjects::TableRow
47
+
46
48
  end # module: WebObjects
47
49
  end # module: Symbiont
@@ -2,8 +2,23 @@ module Symbiont
2
2
  module WebObjects
3
3
 
4
4
  class TextField < WebObject
5
-
5
+ # Get the value of a text field.
6
+ def value
7
+ @web_object.value
8
+ end
9
+
10
+ # Set the value of a text field.
11
+ def value=(value)
12
+ @web_object.set value
13
+ end
14
+
15
+ # Append text to a text field.
16
+ def append(text)
17
+ @web_object.send_keys text
18
+ end
6
19
  end # class: TextField
7
-
20
+
21
+ ::Symbiont::WebObjects.class_for_type[:text] = ::Symbiont::WebObjects::TextField
22
+ ::Symbiont::WebObjects.class_for_type[:password] = ::Symbiont::WebObjects::TextField
8
23
  end # module: WebObjects
9
- end # module: Symbiont
24
+ end # module: Symbiont
@@ -0,0 +1,22 @@
1
+ module Symbiont
2
+ module WebObjects
3
+
4
+ class << self
5
+ def class_for_tag
6
+ @class_for_tag ||= {}
7
+ end
8
+
9
+ def class_for_type
10
+ @class_for_type ||= {}
11
+ end
12
+
13
+ def get_class_for(tag, type=nil)
14
+ return class_for_type[type.to_sym] if type
15
+ class_for_tag[tag.to_sym] || ::Symbiont::WebObjects::WebObject
16
+ end
17
+ end
18
+
19
+ end # module: WebObjects
20
+ end # module: Symbiont
21
+
22
+ require 'symbiont/web_objects/_common'
data/lib/symbiont.rb CHANGED
@@ -5,12 +5,14 @@ require 'symbiont/generators'
5
5
  require 'symbiont/enclosers'
6
6
  require 'symbiont/evaluators'
7
7
  require 'symbiont/locators'
8
+ require 'symbiont/data_setter'
8
9
 
9
10
  module Symbiont
10
11
  include Platforms
11
12
  include Enclosers
12
13
  include Evaluators
13
14
  include Locators
15
+ include DataSetter
14
16
 
15
17
  # Used to make a platform object accessible. Will hold object
16
18
  # references like these:
@@ -0,0 +1,62 @@
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
@@ -10,6 +10,23 @@ describe Symbiont::Enclosers do
10
10
  watir_browser.should_receive(:goto).with("http://localhost:4567")
11
11
  watir_definition.visit("http://localhost:4567")
12
12
  end
13
+
14
+ it "should get the active url" do
15
+ watir_browser.should_receive(:url).and_return("http://localhost:4567")
16
+ watir_definition.url.should == "http://localhost:4567"
17
+ end
18
+
19
+ it "should get a screenshot" do
20
+ watir_browser.should_receive(:wd).and_return(watir_browser)
21
+ watir_browser.should_receive(:save_screenshot)
22
+ watir_definition.screenshot("testing.png")
23
+ end
24
+
25
+ it "should run a script against the browser" do
26
+ watir_browser.should_receive(:execute_script).twice.and_return("input")
27
+ watir_definition.run_script("return document.activeElement").should == "input"
28
+ watir_definition.execute_script("return document.activeElement").should == "input"
29
+ end
13
30
  end
14
31
  end
15
32
 
@@ -19,6 +36,24 @@ describe Symbiont::Enclosers do
19
36
  watir_browser.should_receive(:text).and_return("page text")
20
37
  watir_definition.text.should == "page text"
21
38
  end
39
+
40
+ it "should return all the markup on a page" do
41
+ watir_browser.should_receive(:html).twice.and_return("<h1>Page Title</h1>")
42
+ watir_definition.markup.should == "<h1>Page Title</h1>"
43
+ watir_definition.html.should == "<h1>Page Title</h1>"
44
+ end
45
+
46
+ it "should return the title of a page" do
47
+ watir_browser.should_receive(:title).and_return("Page Title")
48
+ watir_definition.title.should == "Page Title"
49
+ end
50
+
51
+ it "should return the web object that has focus" do
52
+ watir_browser.should_receive(:execute_script).and_return(watir_browser)
53
+ watir_browser.should_receive(:tag_name).twice.and_return(:input)
54
+ watir_browser.should_receive(:type).and_return(:submit)
55
+ watir_definition.focus.class.should == Symbiont::WebObjects::Button
56
+ end
22
57
  end
23
58
  end
24
59
  end
@@ -14,6 +14,11 @@ describe "Web Objects" do
14
14
  watir_definition.style('display').should == 'none'
15
15
  end
16
16
 
17
+ it "should retrieve the tag of a web object" do
18
+ watir_browser.should_receive(:tag_name).and_return("div")
19
+ watir_definition.tag.should == "div"
20
+ end
21
+
17
22
  it "should determine if a web object is enabled" do
18
23
  watir_browser.should_receive(:enabled?).and_return(true)
19
24
  watir_definition.enabled?.should == true
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::WebObjects::Button do
4
+ describe "implementation" do
5
+ let(:button_object) { double('button_object') }
6
+
7
+ it "should register with a submit type" do
8
+ ::Symbiont::WebObjects.get_class_for(:input, :submit).should == ::Symbiont::WebObjects::Button
9
+ end
10
+
11
+ it "should register with a button type" do
12
+ ::Symbiont::WebObjects.get_class_for(:input, :button).should == ::Symbiont::WebObjects::Button
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::WebObjects::CheckBox do
4
+ describe "implementation" do
5
+ let(:checkbox_object) { double('checkbox_object') }
6
+
7
+ it "should register with a submit type" do
8
+ ::Symbiont::WebObjects.get_class_for(:input, :checkbox).should == ::Symbiont::WebObjects::CheckBox
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::WebObjects::Div do
4
+ describe "implementation" do
5
+ let(:div_object) { double('div_object') }
6
+
7
+ it "should register with a div tag" do
8
+ ::Symbiont::WebObjects.get_class_for(:div).should == ::Symbiont::WebObjects::Div
9
+ end
10
+ end
11
+ end