mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Tests for Node#send_keys
This commit is contained in:
parent
0b106dab59
commit
8a7a1dda1d
5 changed files with 36 additions and 1 deletions
|
@ -100,4 +100,7 @@ $(function() {
|
|||
$(this).attr('response', response);
|
||||
}
|
||||
});
|
||||
$('#with-key-events').keydown(function(e){
|
||||
$('#key-events-output').append('keydown:'+e.which+' ')
|
||||
});
|
||||
});
|
||||
|
|
|
@ -251,6 +251,32 @@ Capybara::SpecHelper.spec "node" do
|
|||
expect(@session.find(:css, '#has-been-right-clicked')).to be
|
||||
end
|
||||
end
|
||||
|
||||
describe '#send_keys', requires: [:send_keys] do
|
||||
it "should send a string of keys to an element" do
|
||||
@session.visit('/form')
|
||||
@session.find(:css, '#address1_city').send_keys('Oceanside')
|
||||
expect(@session.find(:css, '#address1_city').value).to eq 'Oceanside'
|
||||
end
|
||||
|
||||
it "should send special characters" do
|
||||
@session.visit('/form')
|
||||
@session.find(:css, '#address1_city').send_keys('Ocean', :space, 'sie', :left, 'd')
|
||||
expect(@session.find(:css, '#address1_city').value).to eq 'Ocean side'
|
||||
end
|
||||
|
||||
it "should allow for multiple simultaneous keys" do
|
||||
@session.visit('/form')
|
||||
@session.find(:css, '#address1_city').send_keys([:shift, 'o'], 'ceanside')
|
||||
expect(@session.find(:css, '#address1_city').value).to eq 'Oceanside'
|
||||
end
|
||||
|
||||
it "should generate key events", requires: [:send_keys, :js] do
|
||||
@session.visit('/with_js')
|
||||
@session.find(:css, '#with-key-events').send_keys([:shift,'t'], [:shift,'w'])
|
||||
expect(@session.find(:css, '#key-events-output')).to have_text('keydown:16 keydown:84 keydown:16 keydown:87')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#reload', :requires => [:js] do
|
||||
context "without automatic reload" do
|
||||
|
|
|
@ -88,7 +88,11 @@
|
|||
<p>
|
||||
<a href="#" id="open-prompt">Open prompt</a>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<input type="test" name="with-key-events" id="with-key-events">
|
||||
<p id="key-events-output"></p>
|
||||
</p>
|
||||
<script type="text/javascript">
|
||||
// a javascript comment
|
||||
var aVar = 123;
|
||||
|
|
|
@ -11,6 +11,7 @@ Capybara::SpecHelper.run_specs TestClass.new, "DSL", :capybara_skip => [
|
|||
:screenshot,
|
||||
:frames,
|
||||
:windows,
|
||||
:send_keys,
|
||||
:server,
|
||||
:hover,
|
||||
:about_scheme,
|
||||
|
|
|
@ -10,6 +10,7 @@ Capybara::SpecHelper.run_specs TestSessions::RackTest, "RackTest", :capybara_ski
|
|||
:screenshot,
|
||||
:frames,
|
||||
:windows,
|
||||
:send_keys,
|
||||
:server,
|
||||
:hover,
|
||||
:about_scheme,
|
||||
|
|
Loading…
Add table
Reference in a new issue