Merge branch 'selenium-clear-input' of git://github.com/DouweM/capybara into DouweM-selenium-clear-input

This commit is contained in:
Jonas Nicklas 2012-11-20 14:32:09 +01:00
commit 7859efb757
2 changed files with 8 additions and 1 deletions

View File

@ -32,7 +32,8 @@ class Capybara::Selenium::Node < Capybara::Driver::Node
path_names = value.to_s.empty? ? [] : value
native.send_keys(*path_names)
elsif tag_name == 'textarea' or tag_name == 'input'
native.send_keys(("\b" * native[:value].size) + value.to_s)
chars = native[:value].size
native.send_keys(([:right] * chars) + ([:backspace] * chars) + [ value.to_s ])
end
end

View File

@ -65,6 +65,12 @@ Capybara::SpecHelper.spec "node" do
@session.first('//input').set('gorilla')
@session.first('//input').value.should == 'gorilla'
end
it "should fill the field even if the caret was not at the end", :requires => [:js] do
@session.execute_script("var el = document.getElementById('test_field'); el.focus(); el.setSelectionRange(0, 0);")
@session.first('//input').set('')
@session.first('//input').value.should == ''
end
end
describe "#tag_name" do