Merge branch 'selenium-clear-input' of git://github.com/DouweM/capybara into DouweM-selenium-clear-input
This commit is contained in:
commit
7859efb757
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue