spectest 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -1,6 +1,17 @@
1
1
  Change Log and History
2
2
  ======================
3
3
 
4
+
5
+ ## Version 0.0.3 / 2011-11-14
6
+
7
+ This update put in place the basic functionality of allowing the platform object to query and manipulate objects. This required the creation of a web object structure. Here "web objects" refer to any elements that appear on a browser web page. When I say "query" these objects, I essentially mean checking if they in fact exist. When I say "manipulate" these objects, I mean do something with them, such as click them or enter information into them. Each platform object has its own identification mechanisms in place.
8
+
9
+ * Web Objects Supported:
10
+ * Links
11
+ * Text Fields
12
+ * Buttons
13
+
14
+
4
15
  ## Version 0.0.2 / 2011-11-13
5
16
 
6
17
  Platform object structure added. This allows browsers to be associated with a particular driver. That combination is called a "platform object." It's this object that directs the execution of tests against the browser. A full RSpec and Cucumber testing infrastructure has been added. The Cucumber file layout will match what users of the gem would have to create.
data/lib/spectest.rb CHANGED
@@ -2,6 +2,7 @@ require "spectest/version"
2
2
  require "spectest/logger"
3
3
  require "spectest/matchers"
4
4
  require "spectest/platforms"
5
+ require "spectest/generators"
5
6
 
6
7
  module SpecTest
7
8
  include Matchers
@@ -15,9 +16,17 @@ module SpecTest
15
16
  "SpecTest version #{SpecTest::VERSION}"
16
17
  end
17
18
 
18
- def initialize(browser)
19
+ # This makes sure that any page classes that include SpecTest will be
20
+ # given access to the generator methods based on web objects that are
21
+ # declared in the page class.
22
+ def self.included(caller)
23
+ caller.extend SpecTest::Generators
24
+ end
25
+
26
+ def initialize(browser, visit=nil)
19
27
  @browser = browser
20
28
  establish_platform_driver_for browser
29
+ goto if visit && respond_to?(:goto)
21
30
  end
22
31
 
23
32
  # Navigate to the specified URL. The URL can be specified as a domain
@@ -47,4 +56,8 @@ module SpecTest
47
56
  def establish_platform_driver_for(browser)
48
57
  @platform = platform_for browser, SpecTest::Platforms.list
49
58
  end
59
+
60
+ def process_block(&block)
61
+ block.arity == 1 ? block.call(self) : self.instance_eval(&block)
62
+ end
50
63
  end
@@ -0,0 +1,78 @@
1
+ module SpecTest
2
+ module Generators
3
+
4
+ # Allows you to specify a direct URL as part of a page object.
5
+ # @param [String] url the address for the page.
6
+ def url_is(url)
7
+ define_method("goto") do
8
+ @platform.navigate_to url
9
+ end
10
+ end
11
+
12
+ # Create methods to do the following:
13
+ # Select a link object.
14
+ # Return a link object.
15
+ # @param [String] identifier how a link will be referred to
16
+ # @param [Hash] locator how a link will be recognized
17
+ # @param [optional] block to be invoked when object method is called
18
+ def link(identifier, locator=nil, &block)
19
+ define_method(identifier) do
20
+ return @platform.click_link_for locator.clone unless block_given?
21
+ self.send("#{identifier}_object").click
22
+ end
23
+
24
+ define_method("#{identifier}_object") do
25
+ return process_block(&block) if block_given?
26
+ @platform.get_link_for locator.clone
27
+ end
28
+
29
+ alias_method "#{identifier}_link".to_sym, "#{identifier}_object".to_sym
30
+ end
31
+
32
+ # Creates methods to do the following:
33
+ # Enter text into a text field object
34
+ # Get the text that is in a text field object
35
+ # Return a text field object.
36
+ # @param [String] identifier how a text field will be referred to
37
+ # @param [Hash] locator how a text field will be recognized
38
+ # @param [optional] block to be invoked when object method is called
39
+ def text_field(identifier, locator=nil, &block)
40
+ define_method(identifier) do
41
+ return @platform.get_text_field_value_for locator.clone unless block_given?
42
+ self.send("#{identifier}_object").value
43
+ end
44
+
45
+ define_method("#{identifier}=") do |value|
46
+ return @platform.set_text_field_value_for(locator.clone, value) unless block_given?
47
+ self.send("{identifier}_object").value = value
48
+ end
49
+
50
+ define_method("#{identifier}_object") do
51
+ return process_block(&block) if block_given?
52
+ @platform.get_text_field_for locator.clone
53
+ end
54
+
55
+ alias_method "#{identifier}_text_field".to_sym, "#{identifier}_object".to_sym
56
+ end
57
+
58
+ # Creates methods to do the following:
59
+ # Click a button object.
60
+ # Return a button object.
61
+ # @param [String] identifier how a button will be referred to
62
+ # @param [Hash] locator how a button will be recognized
63
+ # @param []optional] block to be invoked when object method is called
64
+ def button(identifier, locator=nil, &block)
65
+ define_method(identifier) do
66
+ return @platform.click_button_for locator.clone unless block_given?
67
+ self.send("#{identifer}_object").click
68
+ end
69
+
70
+ define_method("#{identifier}_object") do
71
+ return process_block(&block) if block_given?
72
+ @platform.get_button_for locator.clone
73
+ end
74
+
75
+ alias_method "#{identifier}_button".to_sym, "#{identifier}_object".to_sym
76
+ end
77
+ end
78
+ end
@@ -25,7 +25,94 @@ module SpecTest
25
25
  @browser.find_element(:tag_name, 'body').text
26
26
  end
27
27
 
28
+ # Platform method to return a link object.
29
+ # Link objects are of type: SpecTest::WebObjects::Link
30
+ # See SpecTest::Generators#link
31
+ def get_link_for(locator)
32
+ key, value = get_platform_locator_for(locator, WebObjects::Link, 'a')
33
+ web_object = @browser.find_element(key, value)
34
+ WebObjects::Link.new(web_object, :platform => :selenium_webdriver)
35
+ end
36
+
37
+ # Platform method to click a link object.
38
+ # See SpecTest::Generators#link
39
+ def click_link_for(locator)
40
+ key, value = get_platform_locator_for(locator, WebObjects::Link, 'a')
41
+ @browser.find_element(key, value).click
42
+ end
43
+
44
+ # Platform method to return a text field object.
45
+ # Text field objects are of type: SpecTest::WebObjects::TextField
46
+ # See SpecTest::Generators#text_field
47
+ def get_text_field_for(locator)
48
+ key, value = get_platform_locator_for(locator, WebObjects::TextField, 'input', :type => 'text')
49
+ web_object = @browser.find_element(key, value)
50
+ WebObjects::TextField.new(web_object, :platform => :selenium_webdriver)
51
+ end
52
+
53
+ # Platform method to get the value in a text field object.
54
+ # See SpecTest::Generators#text_field
55
+ def get_text_field_value_for(locator)
56
+ key, value = get_platform_locator_for(locator, WebObjects::TextField, 'input', :type => 'text')
57
+ value = @browser.find_element(key, value).attribute('value')
58
+ value
59
+ end
60
+
61
+ # Platform method to set a value in a text field object.
62
+ # See SpecTest::Generators#text_field
63
+ def set_text_field_value_for(locator, text)
64
+ key, value = get_platform_locator_for(locator, WebObjects::TextField, 'input', :type => 'text')
65
+ @browser.find_element(key, value).clear
66
+ @browser.find_element(key, value).send_keys(text)
67
+ end
68
+
69
+ # Platform method to return a button object.
70
+ # Button objects are of type: SpecTest::WebObjects::Button
71
+ # See SpecTest::Generators#button
72
+ def get_button_for(locator)
73
+ key, value = get_platform_locator_for(locator, WebObjects::Button, 'input', :type => 'submit')
74
+ web_object = @browser.find_element(key, value)
75
+ WebObjects::Button.new(web_object, :platform => :selenium_webdriver)
76
+ end
77
+
78
+ # Platform method to click a button object.
79
+ # See SpecTest::Generators#button
80
+ def click_button_for(locator)
81
+ key, value = get_platform_locator_for(locator, WebObjects::Button, 'input', :type => 'submit')
82
+ @browser.find_element(key, value).click
83
+ end
84
+
85
+ protected
86
+
87
+ def get_platform_locator_for(locator, web_object, tag=nil, qualifier=nil)
88
+ locator = qualify_with_tagname_for locator, tag, qualifier if tag
89
+ key, value = web_object.have_selenium_find_object_with locator
90
+ return key, value
91
+ end
92
+
93
+ def qualify_with_tagname_for(locator, tag, qualifier=nil)
94
+ return locator if locator.length < 2 and support_is_provided_for locator, tag, qualifier
95
+ locator[:tag_name] = tag
96
+ if qualifier
97
+ qualifier.each do |key, value|
98
+ locator[key] = value
99
+ end
100
+ end
101
+ locator
102
+ end
103
+
104
+ def support_is_provided_for(locator, tag, qualifier)
105
+ return false if locator[:index]
106
+ return false if locator[:text] and tag == 'input' and qualifier[:type] == 'hidden'
107
+ return false if locator[:href] and tag == 'a'
108
+ return false if locator[:text] and ['div', 'span', 'td'].include? tag
109
+ return false if locator[:value] and tag == 'input' and qualifier[:type] == 'submit'
110
+ return false if locator[:value] and tag == 'input' and qualifier[:type] == 'radio'
111
+ true
112
+ end
28
113
  end
29
114
  end
30
115
  end
31
- end
116
+ end
117
+
118
+ Dir["#{File.dirname(__FILE__)}/../web_objects/**/*.rb"].each { |file| require file }
@@ -27,7 +27,78 @@ module SpecTest
27
27
  @browser.text
28
28
  end
29
29
 
30
+ # Platform method to return a link object.
31
+ # Link objects are of type: SpecTest::WebObjects::Link
32
+ # See SpecTest::Generators#link
33
+ def get_link_for(locator)
34
+ locator = get_platform_locator_for(locator, WebObjects::Link)
35
+ web_object = @browser.instance_eval "link(locator)"
36
+ WebObjects::Link.new(web_object, :platform => :watir_webdriver)
37
+ end
38
+
39
+ # Platform method to click a link object.
40
+ # See SpecTest::Generators#link
41
+ def click_link_for(locator)
42
+ locator = get_platform_locator_for(locator, WebObjects::Link)
43
+ @browser.instance_eval "link(locator).click if locator"
44
+ end
45
+
46
+ # Platform method to return a text field object.
47
+ # Text field objects are of type: SpecTest::WebObjects::TextField
48
+ # See SpecTest::Generators#text_field
49
+ def get_text_field_for(locator)
50
+ identifier = get_platform_locator_for(locator, WebObjects::TextField)
51
+ web_object = @browser.instance_eval "text_field(locator)"
52
+ WebObjects::TextField.new(web_object, :platform => :watir_webdriver)
53
+ end
54
+
55
+ # Platform method to get the value in a text field object.
56
+ # See SpecTest::Generators#text_field
57
+ def get_text_field_value_for(locator)
58
+ identifier = get_platform_locator_for(locator, WebObjects::TextField)
59
+ value = @browser.instance_eval "text_field(locator).value"
60
+ value
61
+ end
62
+
63
+ # Platform method to set a value in a text field object.
64
+ # See SpecTest::Generators#text_field
65
+ def set_text_field_value_for(locator, text)
66
+ identifier = get_platform_locator_for(locator, WebObjects::TextField)
67
+ @browser.instance_eval "text_field(locator).set(text)"
68
+ end
69
+
70
+ # Platform method to return a button object.
71
+ # Button objects are of type: SpecTest::WebObjects::Button
72
+ # See SpecTest::Generators#button
73
+ def get_button_for(locator)
74
+ identifier = get_platform_locator_for(locator, WebObjects::Button)
75
+ web_object = @browser.instance_eval "button(locator)"
76
+ WebObjects::Button.new(web_object, :platform => :watir_webdriver)
77
+ end
78
+
79
+ # Platform method to click a button object.
80
+ # See SpecTest::Generators#button
81
+ def click_button_for(locator)
82
+ identifier = get_platform_locator_for(locator, WebObjects::Button)
83
+ @browser.instance_eval "button(locator).click"
84
+ end
85
+
86
+ protected
87
+
88
+ def get_platform_locator_for(locator, web_object, tag=nil)
89
+ locator = qualify_with_tagname_for locator, tag if tag
90
+ locator = web_object.have_watir_find_object_with locator
91
+ return locator
92
+ end
93
+
94
+ def qualify_with_tagname_for(locator, tag)
95
+ return locator if locator.length < 2 and not locator[:name]
96
+ locator[:tag_name] = tag if locator[:name]
97
+ locator
98
+ end
30
99
  end
31
100
  end
32
101
  end
33
- end
102
+ end
103
+
104
+ Dir["#{File.dirname(__FILE__)}/../web_objects/**/*.rb"].each { |file| require file }
@@ -1,3 +1,3 @@
1
1
  module SpecTest
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,53 @@
1
+ module SpecTest
2
+ module WebObjects
3
+ class WebObject
4
+ def self.have_watir_find_object_with(locator)
5
+ locator_list = {}
6
+
7
+ locator.each do |key, value|
8
+ current = {key => value}
9
+ SpecTest::trace("What I got: #{current}")
10
+ object_locator = locator_for(current, locators_for_watir, mappings_for_watir)
11
+ SpecTest::trace("What I gave: #{object_locator}")
12
+ locator_list[object_locator.keys.first] = object_locator.values.first
13
+ end
14
+
15
+ locator_list
16
+ end
17
+
18
+ def self.have_selenium_find_object_with(locator)
19
+ if locator.length == 1
20
+ SpecTest::trace("What I got: #{locator}")
21
+ object_locator = locator_for(locator, locators_for_selenium, mappings_for_selenium)
22
+ SpecTest::trace("What I gave: #{object_locator}")
23
+ return object_locator.keys.first, object_locator.values.first
24
+ end
25
+ end
26
+
27
+ protected
28
+
29
+ def self.locator_for(locator, direct_find, mapping_find)
30
+ key, value = locator.keys.first, locator.values.first
31
+ return key => value if direct_find.include? key
32
+ return mapping_find[key] => value if mapping_find[key]
33
+ return nil => value
34
+ end
35
+
36
+ def self.locators_for_watir
37
+ [:class, :id, :index, :name, :xpath]
38
+ end
39
+
40
+ def self.mappings_for_watir
41
+ {}
42
+ end
43
+
44
+ def self.locators_for_selenium
45
+ [:class, :id, :index, :name, :xpath]
46
+ end
47
+
48
+ def self.mappings_for_selenium
49
+ {}
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,17 @@
1
+ module SpecTest
2
+ module WebObjects
3
+ class Button < WebObject
4
+
5
+ protected
6
+
7
+ def self.locators_for_watir
8
+ super + [:text, :value]
9
+ end
10
+
11
+ def self.locators_for_selenium
12
+ super + [:value]
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,24 @@
1
+ module SpecTest
2
+ module WebObjects
3
+ class Link < WebObject
4
+
5
+ protected
6
+
7
+ def self.locators_for_watir
8
+ super + [:href, :text]
9
+ end
10
+
11
+ def self.mappings_for_watir
12
+ super.merge({:link => :text, :link_text => :text})
13
+ end
14
+
15
+ def self.locators_for_selenium
16
+ super + [:link, :link_text]
17
+ end
18
+
19
+ def self.mappings_for_selenium
20
+ super.merge(:text => :link_text)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,25 @@
1
+ module SpecTest
2
+ module WebObjects
3
+ class TextField < WebObject
4
+
5
+ protected
6
+
7
+ def self.locators_for_watir
8
+ super + [:tag_name]
9
+ end
10
+
11
+ def self.mappings_for_watir
12
+ super.merge({:css => :tag_name})
13
+ end
14
+
15
+ def self.locators_for_selenium
16
+ super + [:css]
17
+ end
18
+
19
+ def self.mappings_for_selenium
20
+ super.merge({:tag_name => :css})
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,182 @@
1
+ require "spec_helper"
2
+
3
+ class TestPage
4
+ include SpecTest
5
+
6
+ url_is "http://localhost:1234"
7
+
8
+ link :static_text_examples, :text => "Static Text Examples"
9
+ link :static_text_examples_b do |this| "testing" end
10
+ text_field :server, :id => "server"
11
+ text_field :server_b do |this| "testing" end
12
+ button :submit, :id => "submit"
13
+ button :submit_b do |content| "testing" end
14
+ end
15
+
16
+ class TestingPage
17
+ include SpecTest
18
+ end
19
+
20
+ describe SpecTest::Generators do
21
+ let(:watir_browser) { mock_browser_with_watir }
22
+ let(:selenium_browser) { mock_browser_with_selenium }
23
+ let(:watir_page) { TestPage.new(watir_browser) }
24
+ let(:selenium_page) { TestPage.new(selenium_browser) }
25
+
26
+ describe "there are page objects that contain location information" do
27
+ context "which means" do
28
+ it "it should navigate to a page when requested" do
29
+ watir_browser.should_receive(:goto)
30
+ page = TestPage.new(watir_browser, true)
31
+ end
32
+
33
+ it "it should not navigate to a page when not requested" do
34
+ watir_browser.should_not_receive(:goto)
35
+ page = TestPage.new(watir_browser)
36
+ end
37
+
38
+ it "it should not navigate to a page when a url is not specified" do
39
+ watir_browser.should_not_receive(:goto)
40
+ page = TestingPage.new(watir_browser, true)
41
+ end
42
+ end
43
+ end
44
+
45
+ describe "there are link generators" do
46
+ context "and when a link is declared on a page" do
47
+ it "methods for querying and manipulating the link should be generated" do
48
+ watir_page.should respond_to(:static_text_examples)
49
+ watir_page.should respond_to(:static_text_examples_object)
50
+ watir_page.should respond_to(:static_text_examples_link)
51
+ end
52
+
53
+ it "blocks declared with the object will be executed" do
54
+ watir_page.static_text_examples_b_link.should == "testing"
55
+ end
56
+ end
57
+
58
+ context "and when used on the watir platform implementation" do
59
+ it "it should be possible to find a link object" do
60
+ watir_browser.should_receive(:link).and_return(watir_browser)
61
+ web_object = watir_page.static_text_examples_object
62
+ web_object.should be_instance_of SpecTest::WebObjects::Link
63
+ end
64
+
65
+ it "it should be possible to select (and thus click) a link" do
66
+ watir_browser.stub_chain(:link, :click)
67
+ watir_page.static_text_examples
68
+ end
69
+ end
70
+
71
+ context "and when used on the selenium platform implementation" do
72
+ it "it should be possible to find a link object" do
73
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
74
+ web_object = selenium_page.static_text_examples_object
75
+ web_object.should be_instance_of SpecTest::WebObjects::Link
76
+ end
77
+
78
+ it "it should be possible to select (and thus click) a link" do
79
+ selenium_browser.stub_chain(:find_element, :click)
80
+ selenium_page.static_text_examples
81
+ end
82
+ end
83
+ end
84
+
85
+ describe "there are text field generators" do
86
+ context "and when a text field is declared on a page" do
87
+ it "methods for querying and manipulating the text field should be generated" do
88
+ watir_page.should respond_to(:server)
89
+ watir_page.should respond_to(:server=)
90
+ watir_page.should respond_to(:server_object)
91
+ watir_page.should respond_to(:server_text_field)
92
+ end
93
+
94
+ it "blocks declared with the object will be executed" do
95
+ watir_page.server_b_object.should == "testing"
96
+ end
97
+ end
98
+
99
+ context "and when used on the watir platform implementation" do
100
+ it "it should be possible to find a text field object" do
101
+ watir_browser.should_receive(:text_field).and_return(watir_browser)
102
+ web_object = watir_page.server_object
103
+ web_object.should be_instance_of SpecTest::WebObjects::TextField
104
+ end
105
+
106
+ it "it should be possible to get the text from a text field" do
107
+ watir_browser.should_receive(:text_field).and_return(watir_browser)
108
+ watir_browser.should_receive(:value).and_return("Testing")
109
+ watir_page.server.should == "Testing"
110
+ end
111
+
112
+ it "it should be possible to type text into a text field" do
113
+ watir_browser.should_receive(:text_field).and_return(watir_browser)
114
+ watir_browser.should_receive(:set).with("Testing")
115
+ watir_page.server = "Testing"
116
+ end
117
+ end
118
+
119
+ context "and when used on the selenium platform implementation" do
120
+ it "it should be possible to find a text field object" do
121
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
122
+ web_object = selenium_page.server_object
123
+ web_object.should be_instance_of SpecTest::WebObjects::TextField
124
+ end
125
+
126
+ it "it should be possible to get the text from a text field" do
127
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
128
+ selenium_browser.should_receive(:attribute).with('value').and_return("Testing")
129
+ selenium_page.server.should == "Testing"
130
+ end
131
+
132
+ it "it should be possible to type text into a text field" do
133
+ selenium_browser.should_receive(:find_element).twice.and_return(selenium_browser)
134
+ selenium_browser.should_receive(:clear)
135
+ selenium_browser.should_receive(:send_keys).with("Testing")
136
+ selenium_page.server = "Testing"
137
+ end
138
+ end
139
+ end
140
+
141
+ describe "there are button generators" do
142
+ context "and when a button is declared on a page" do
143
+ it "methods for querying and manipulating the button should be generated" do
144
+ watir_page.should respond_to(:submit)
145
+ watir_page.should respond_to(:submit_object)
146
+ watir_page.should respond_to(:submit_button)
147
+ end
148
+
149
+ it "blocks declared with the object will be executed" do
150
+ watir_page.submit_b_object.should == "testing"
151
+ end
152
+ end
153
+
154
+ context "and when used on the watir platform implementation" do
155
+ it "it should be possible to find a button object" do
156
+ watir_browser.should_receive(:button).and_return(watir_browser)
157
+ web_object = watir_page.submit_object
158
+ web_object.should be_instance_of SpecTest::WebObjects::Button
159
+ end
160
+
161
+ it "it should be possible to click a button object" do
162
+ watir_browser.should_receive(:button).and_return(watir_browser)
163
+ watir_browser.should_receive(:click)
164
+ watir_page.submit
165
+ end
166
+ end
167
+
168
+ context "and when used on the selenium platform implementation" do
169
+ it "it should be possible to find a button object" do
170
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
171
+ web_object = selenium_page.submit_object
172
+ web_object.should be_instance_of SpecTest::WebObjects::Button
173
+ end
174
+
175
+ it "it should be possible to click a button object" do
176
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
177
+ selenium_browser.should_receive(:click)
178
+ selenium_page.submit
179
+ end
180
+ end
181
+ end
182
+ end
@@ -6,7 +6,7 @@ After do |scenario|
6
6
  # I don't believe the following line works at all because I don't think Cucumber
7
7
  # (on Windows at least) actually runs the After logic unless a scenario is either
8
8
  # failing or succeeding. I'll keep this line in until I can investigate further.
9
- @KEEP_OPEN = true if scenario.status == :pending or scenario.status == :undefined
9
+ #@KEEP_OPEN = true if scenario.status == :pending or scenario.status == :undefined
10
10
  end
11
11
 
12
12
  AfterConfiguration do |config|
@@ -0,0 +1,7 @@
1
+ class FormExamplesPage
2
+ include SpecTest
3
+
4
+ text_field :server, :id => "server"
5
+ text_field :customer_code, :id => "customerCode"
6
+ button :login, :id => "btnSubmit"
7
+ end
@@ -1,4 +1,7 @@
1
1
  class LandingPage
2
2
  include SpecTest
3
-
3
+
4
+ url_is "http://localhost:1234"
5
+ link :static_text_examples, :text => "Static Text Examples"
6
+ link :form_examples, :text => "Form Examples"
4
7
  end
@@ -0,0 +1,4 @@
1
+ class StaticExamplesPage
2
+ include SpecTest
3
+
4
+ end
@@ -0,0 +1,3 @@
1
+ class Success1Page
2
+ include SpecTest
3
+ end
@@ -0,0 +1,3 @@
1
+ When /^I click the log in button$/ do
2
+ @page.login
3
+ end
@@ -0,0 +1,3 @@
1
+ When /^I select the static text examples link$/ do
2
+ @page.static_text_examples
3
+ end
@@ -0,0 +1,3 @@
1
+ Then /^I should see the text "([^"]*)"$/ do |text|
2
+ @text.should == text
3
+ end
@@ -1,6 +1,16 @@
1
1
  Given /^I have gone to the test app site$/ do
2
- @page = LandingPage.new(@browser)
3
- @page.navigate_to("http://localhost:1234")
2
+ @page = LandingPage.new(@browser, true)
3
+ #@page.navigate_to("http://localhost:1234")
4
+ end
5
+
6
+ Given /^I am on the landing page$/ do
7
+ step %{I have gone to the test app site}
8
+ end
9
+
10
+ Given /^I am on the form examples page$/ do
11
+ step %{I have gone to the test app site}
12
+ @page.form_examples
13
+ @page = FormExamplesPage.new(@browser)
4
14
  end
5
15
 
6
16
  Then /^I should be on the landing page$/ do
@@ -8,4 +18,15 @@ Then /^I should be on the landing page$/ do
8
18
  #@page.title.should match(/^Test App$/)
9
19
  @page.text.should contain("Landing Page")
10
20
  @page.title.should have_title("Test App")
21
+ end
22
+
23
+ Then /^I should be on the static text examples page$/ do
24
+ @page = StaticExamplesPage.new(@browser)
25
+ @page.text.should contain("Static Text Page")
26
+ @page.title.should have_title("Static Text Testing")
27
+ end
28
+
29
+ Then /^I should be taken to the first success page$/ do
30
+ @page = Success1Page.new(@browser)
31
+ @page.text.should contain("first success page")
11
32
  end
@@ -0,0 +1,8 @@
1
+ When /^I check the text of the server text field$/ do
2
+ @text = @page.server
3
+ end
4
+
5
+ When /^I enter "([^"]*)" in the customer code text field$/ do |text|
6
+ @page.customer_code = text
7
+ @text = @page.customer_code
8
+ end
@@ -0,0 +1,13 @@
1
+ Feature: Ability to support buttons.
2
+
3
+ As a test writer
4
+ I need the ability to click a button
5
+ so that I can generate events
6
+ and so that I can submit forms.
7
+
8
+ Background:
9
+ Given I am on the form examples page
10
+
11
+ Scenario: Clicking a button. (Specific test step.)
12
+ When I click the log in button
13
+ Then I should be taken to the first success page
@@ -0,0 +1,12 @@
1
+ Feature: Ability to support links.
2
+
3
+ As a test writer
4
+ I need the ability to click on links
5
+ so that I can use link-based navigation while testing.
6
+
7
+ Background:
8
+ Given I am on the landing page
9
+
10
+ Scenario: Selecting a link. (Specific test step.)
11
+ When I select the static text examples link
12
+ Then I should be on the static text examples page
@@ -1,9 +1,9 @@
1
1
  Feature: Ability to support page viewing.
2
2
 
3
- As a test writer,
4
- I need the ability to get to pages
5
- so that I can actually do some testing.
3
+ As a test writer,
4
+ I need the ability to get to pages
5
+ so that I can actually do some testing.
6
6
 
7
- Scenario: Navigating to a page.
8
- Given I have gone to the test app site
9
- Then I should be on the landing page
7
+ Scenario: Navigating to a page.
8
+ Given I have gone to the test app site
9
+ Then I should be on the landing page
@@ -0,0 +1,21 @@
1
+ Feature: Ability to support text fields.
2
+
3
+ As a test writer
4
+ I need the ability to get the text from a text field
5
+ so that I can verify default text
6
+ and so that I can verify text I have entered.
7
+
8
+ As a test writer
9
+ I need the ability to enter text into a text field
10
+ so that I can manipulate form elements.
11
+
12
+ Background:
13
+ Given I am on the form examples page
14
+
15
+ Scenario: Getting the value from a text field
16
+ When I check the text of the server text field
17
+ Then I should see the text "Test"
18
+
19
+ Scenario: Setting the value of a text field
20
+ When I enter "QA" in the customer code text field
21
+ Then I should see the text "QA"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spectest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-13 00:00:00.000000000Z
12
+ date: 2011-11-14 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: watir-webdriver
16
- requirement: &4716876 !ruby/object:Gem::Requirement
16
+ requirement: &16039692 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.3.9
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *4716876
24
+ version_requirements: *16039692
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: selenium-webdriver
27
- requirement: &4715880 !ruby/object:Gem::Requirement
27
+ requirement: &16038840 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.12.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *4715880
35
+ version_requirements: *16038840
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &4715268 !ruby/object:Gem::Requirement
38
+ requirement: &16038348 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.7.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *4715268
46
+ version_requirements: *16038348
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: cucumber
49
- requirement: &4714728 !ruby/object:Gem::Requirement
49
+ requirement: &16037904 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.1.2
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *4714728
57
+ version_requirements: *16037904
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &4714200 !ruby/object:Gem::Requirement
60
+ requirement: &16037172 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 0.5.4
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *4714200
68
+ version_requirements: *16037172
69
69
  description: Test framework for specifying tests and executing tests.
70
70
  email:
71
71
  - jeffnyman@gmail.com
@@ -82,6 +82,7 @@ files:
82
82
  - Rakefile
83
83
  - cucumber.yml
84
84
  - lib/spectest.rb
85
+ - lib/spectest/generators.rb
85
86
  - lib/spectest/logger.rb
86
87
  - lib/spectest/matchers.rb
87
88
  - lib/spectest/platform_selenium.rb
@@ -90,7 +91,12 @@ files:
90
91
  - lib/spectest/platform_watir/platform_object.rb
91
92
  - lib/spectest/platforms.rb
92
93
  - lib/spectest/version.rb
94
+ - lib/spectest/web_objects/all.rb
95
+ - lib/spectest/web_objects/button.rb
96
+ - lib/spectest/web_objects/link.rb
97
+ - lib/spectest/web_objects/text_field.rb
93
98
  - spec/browser_level_spec.rb
99
+ - spec/generators_spec.rb
94
100
  - spec/page_level_spec.rb
95
101
  - spec/platform_object_spec.rb
96
102
  - spec/platform_selenium_spec.rb
@@ -114,9 +120,19 @@ files:
114
120
  - specs/app/test_static.html
115
121
  - specs/engine/borg.rb
116
122
  - specs/engine/hooks.rb
123
+ - specs/pages/form_examples_page.rb
117
124
  - specs/pages/landing_page.rb
125
+ - specs/pages/static_examples_page.rb
126
+ - specs/pages/success_1_page.rb
127
+ - specs/steps/button_steps.rb
128
+ - specs/steps/link_steps.rb
129
+ - specs/steps/object_steps.rb
118
130
  - specs/steps/page_steps.rb
131
+ - specs/steps/text_field_steps.rb
132
+ - specs/tests/button.feature
133
+ - specs/tests/link.feature
119
134
  - specs/tests/page.feature
135
+ - specs/tests/text_field.feature
120
136
  - spectest.gemspec
121
137
  homepage: https://github.com/jnyman/spectest
122
138
  licenses: