mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Add double_click and right_click to element - support in selenium
This commit is contained in:
parent
52e0caf66c
commit
0aa6aa5b43
6 changed files with 58 additions and 1 deletions
|
@ -41,6 +41,14 @@ module Capybara
|
|||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def right_click
|
||||
raise NotImplmentedError
|
||||
end
|
||||
|
||||
def double_click
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def hover
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
|
|
@ -118,6 +118,22 @@ module Capybara
|
|||
synchronize { base.click }
|
||||
end
|
||||
|
||||
##
|
||||
#
|
||||
# Right Click the Element
|
||||
#
|
||||
def right_click
|
||||
synchronize { base.right_click }
|
||||
end
|
||||
|
||||
##
|
||||
#
|
||||
# Double Click the Element
|
||||
#
|
||||
def double_click
|
||||
synchronize { base.double_click }
|
||||
end
|
||||
|
||||
##
|
||||
#
|
||||
# Hover on the Element
|
||||
|
|
|
@ -58,6 +58,14 @@ class Capybara::Selenium::Node < Capybara::Driver::Node
|
|||
native.click
|
||||
end
|
||||
|
||||
def right_click
|
||||
driver.browser.action.context_click(native).perform
|
||||
end
|
||||
|
||||
def double_click
|
||||
driver.browser.action.double_click(native).perform
|
||||
end
|
||||
|
||||
def hover
|
||||
driver.browser.action.move_to(native).perform
|
||||
end
|
||||
|
|
|
@ -60,4 +60,11 @@ $(function() {
|
|||
$('title').text('changed title')
|
||||
}, 250)
|
||||
});
|
||||
$('#click-test').dblclick(function() {
|
||||
$(this).after('<a id="has-been-double-clicked" href="#">Has been double clicked</a>');
|
||||
});
|
||||
$('#click-test').bind('contextmenu', function(e) {
|
||||
e.preventDefault();
|
||||
$(this).after('<a id="has-been-right-clicked" href="#">Has been right clicked</a>');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -186,6 +186,22 @@ Capybara::SpecHelper.spec "node" do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#double_click', :requires => [:js] do
|
||||
it "should double click an element" do
|
||||
@session.visit('/with_js')
|
||||
@session.find(:css, '#click-test').double_click
|
||||
@session.find(:css, '#has-been-double-clicked').should be
|
||||
end
|
||||
end
|
||||
|
||||
describe '#right_click', :requires => [:js] do
|
||||
it "should double click an element" do
|
||||
@session.visit('/with_js')
|
||||
@session.find(:css, '#click-test').right_click
|
||||
@session.find(:css, '#has-been-right-clicked').should be
|
||||
end
|
||||
end
|
||||
|
||||
describe '#reload', :requires => [:js] do
|
||||
context "without automatic reload" do
|
||||
before { Capybara.automatic_reload = false }
|
||||
|
|
|
@ -62,6 +62,8 @@
|
|||
<a href="#" id="change-title">Change title</a>
|
||||
</p>
|
||||
|
||||
<p id="click-test">Click me</p>
|
||||
|
||||
<script type="text/javascript">
|
||||
// a javascript comment
|
||||
var aVar = 123;
|
||||
|
|
Loading…
Reference in a new issue