Merge pull request #1079 from twalpole/double_click
Add double_click and right_click to element - support in selenium
This commit is contained in:
commit
081aba7e23
|
@ -41,6 +41,14 @@ module Capybara
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def right_click
|
||||||
|
raise NotImplmentedError
|
||||||
|
end
|
||||||
|
|
||||||
|
def double_click
|
||||||
|
raise NotImplementedError
|
||||||
|
end
|
||||||
|
|
||||||
def hover
|
def hover
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
|
@ -118,6 +118,22 @@ module Capybara
|
||||||
synchronize { base.click }
|
synchronize { base.click }
|
||||||
end
|
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
|
# Hover on the Element
|
||||||
|
|
|
@ -71,6 +71,14 @@ class Capybara::Selenium::Node < Capybara::Driver::Node
|
||||||
native.click
|
native.click
|
||||||
end
|
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
|
def hover
|
||||||
driver.browser.action.move_to(native).perform
|
driver.browser.action.move_to(native).perform
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,4 +60,11 @@ $(function() {
|
||||||
$('title').text('changed title')
|
$('title').text('changed title')
|
||||||
}, 250)
|
}, 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>');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -221,6 +221,22 @@ Capybara::SpecHelper.spec "node" do
|
||||||
end
|
end
|
||||||
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
|
describe '#reload', :requires => [:js] do
|
||||||
context "without automatic reload" do
|
context "without automatic reload" do
|
||||||
before { Capybara.automatic_reload = false }
|
before { Capybara.automatic_reload = false }
|
||||||
|
|
|
@ -70,6 +70,8 @@
|
||||||
<a href="#" id="change-title">Change title</a>
|
<a href="#" id="change-title">Change title</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p id="click-test">Click me</p>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// a javascript comment
|
// a javascript comment
|
||||||
var aVar = 123;
|
var aVar = 123;
|
||||||
|
|
Loading…
Reference in New Issue