bjeanes-capybara 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/capybara.rb +1 -1
- data/lib/capybara/xpath.rb +1 -0
- data/spec/dsl/click_button_spec.rb +12 -0
- data/spec/views/form.erb +1 -1
- metadata +1 -1
data/lib/capybara.rb
CHANGED
data/lib/capybara/xpath.rb
CHANGED
@@ -80,6 +80,7 @@ module Capybara
|
|
80
80
|
xpath = append("//input[@type='submit' or @type='image' or @type='button'][@id=#{s(locator)} or contains(@value,#{s(locator)})]")
|
81
81
|
xpath = xpath.append("//button[@id=#{s(locator)} or contains(@value,#{s(locator)}) or contains(.,#{s(locator)})]")
|
82
82
|
xpath = xpath.prepend("//input[@type='submit' or @type='image' or @type='button'][@value=#{s(locator)}]")
|
83
|
+
xpath = xpath.prepend("//input[@type='image'][@alt=#{s(locator)} or contains(@alt,#{s(locator)})]")
|
83
84
|
xpath = xpath.prepend("//button[@value=#{s(locator)} or text()=#{s(locator)}]")
|
84
85
|
end
|
85
86
|
|
@@ -113,6 +113,18 @@ shared_examples_for "click_button" do
|
|
113
113
|
@session.body.should include('You landed')
|
114
114
|
end
|
115
115
|
end
|
116
|
+
|
117
|
+
context "with alt given on an image button" do
|
118
|
+
it "should submit the associated form" do
|
119
|
+
@session.click_button('oh hai thar')
|
120
|
+
extract_results(@session)['first_name'].should == 'John'
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should work with partial matches" do
|
124
|
+
@session.click_button('hai')
|
125
|
+
extract_results(@session)['first_name'].should == 'John'
|
126
|
+
end
|
127
|
+
end
|
116
128
|
|
117
129
|
context "with value given on an image button" do
|
118
130
|
it "should submit the associated form" do
|
data/spec/views/form.erb
CHANGED
@@ -151,7 +151,7 @@
|
|
151
151
|
<input type="button" name="form[fresh]" id="fresh_btn" value="i am fresh"/>
|
152
152
|
<input type="submit" name="form[awesome]" id="awe123" value="awesome"/>
|
153
153
|
<input type="submit" name="form[crappy]" id="crap321" value="crappy"/>
|
154
|
-
<input type="image" name="form[okay]" id="okay556" value="okay"/>
|
154
|
+
<input type="image" name="form[okay]" id="okay556" value="okay" alt="oh hai thar"/>
|
155
155
|
<button type="submit" id="click_me_123" value="click_me">Click me!</button>
|
156
156
|
</p>
|
157
157
|
</form>
|