Permalink
Browse files

Merge pull request #1079 from twalpole/double_click

Add double_click and right_click to element - support in selenium
  • Loading branch information...
2 parents 636391e + 0aa6aa5 commit 081aba7e23a2a5eab7b0c62c0d6c5941eb4d45f3 @jnicklas jnicklas committed Nov 26, 2013
@@ -40,7 +40,15 @@ def unselect_option
def click
raise NotImplementedError
end
-
+
+ def right_click
+ raise NotImplmentedError
+ end
+
+ def double_click
+ raise NotImplementedError
+ end
+
def hover
raise NotImplementedError
end
@@ -120,6 +120,22 @@ def click
##
#
+ # 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
#
def hover
@@ -70,6 +70,14 @@ def unselect_option
def click
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
@@ -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>');
+ });
});
@@ -220,6 +220,22 @@
@session.find(:css, '.hidden_until_hover', :visible => false).should be_visible
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
@@ -69,6 +69,8 @@
<p>
<a href="#" id="change-title">Change title</a>
</p>
+
+ <p id="click-test">Click me</p>
<script type="text/javascript">
// a javascript comment

0 comments on commit 081aba7

Please sign in to comment.