Skip to content

Commit 201b3bd

Browse files
authored
Merge pull request #136 from norman/fix-color-inputs
Fix color inputs
2 parents 0f5b3ea + 84f6d80 commit 201b3bd

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

lib/capybara/cuprite/node.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ def set(value, options = {})
104104
when "file"
105105
files = value.respond_to?(:to_ary) ? value.to_ary.map(&:to_s) : value.to_s
106106
command(:select_file, files)
107+
when "color"
108+
node.evaluate("this.setAttribute('value', '#{value}')")
107109
else
108110
command(:set, value.to_s)
109111
end

spec/integration/session_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@
241241
FileUtils.rm_f(filename)
242242
end
243243
end
244+
245+
it "sets a value for a color input" do
246+
element = @session.find(:css, "#change_me_color")
247+
element.set("#ddeeff")
248+
expect(element.value).to eq("#ddeeff")
249+
end
244250
end
245251

246252
describe "Node#visible" do

spec/support/views/with_js.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<input type="text" name="change_me_withname" id="change_me_withname">
3939
</p>
4040
<p><input type="file" name="change_me_file" id="change_me_file"></p>
41+
<p><input type="color" name="change_me_color" id="change_me_color"></p>
4142
<p id="changes"></p>
4243
<p id="changes_on_input"></p>
4344
<p id="changes_on_keydown"></p>

0 commit comments

Comments
 (0)