New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Touch API #1289
base: master
Are you sure you want to change the base?
Touch API #1289
Changes from 5 commits
9a22ea7
3dcc300
e7ce0d4
a679442
d7c3bf3
58aab76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ chromedriver.log | |
bundler_stubs | ||
bin | ||
gem-private_key.pem | ||
sauce_connect.log |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,7 +82,31 @@ def double_click | |
def hover | ||
driver.browser.action.move_to(native).perform | ||
end | ||
|
||
def single_tap | ||
driver.browser.touch.single_tap(native).perform | ||
end | ||
|
||
def double_tap | ||
driver.browser.touch.double_tap(native).perform | ||
end | ||
|
||
def long_press | ||
#driver.browser.touch.long_press(native).perform | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be uncommented. I think you commented it because Android driver doesn't support There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it's commented because it didn't work, so I manually did the long press with a delay |
||
loc = native.location | ||
driver.browser.touch.down(loc.x, loc.y).perform | ||
sleep(0.8) | ||
driver.browser.touch.up(loc.x, loc.y).perform | ||
end | ||
|
||
def flick(*args) | ||
driver.browser.touch.flick(native, *extract_directions(*args), :fast).perform | ||
end | ||
|
||
def swipe(*args) | ||
driver.browser.touch.flick(native, *extract_directions(*args), :normal).perform | ||
end | ||
|
||
def drag_to(element) | ||
driver.browser.action.drag_and_drop(native, element.native).perform | ||
end | ||
|
@@ -121,6 +145,14 @@ def ==(other) | |
|
||
private | ||
|
||
def extract_directions(*args) | ||
directions = if args.last.is_a?(Hash) then args.pop else {} end | ||
directions.default = 0 | ||
args.each { |arg| directions[arg] = 200 } | ||
x = directions[:right] - directions[:left] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its the direction of swipe |
||
y = directions[:down] - directions[:up] | ||
[x,y] | ||
end | ||
# a reference to the select node if this is an option node | ||
def select_node | ||
find_xpath('./ancestor::select').first | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
$(function() { | ||
$('#touchable').on({ | ||
longTap: function() { | ||
$(this).text('Long pressed'); | ||
$(this).after('<div>Long pressed</div>'); | ||
return false; | ||
}, | ||
swipe: function() { | ||
$(this).text('Flicked'); | ||
return false; | ||
}, | ||
singleTap: function() { | ||
$(this).text('Tapped'); | ||
return false; | ||
}, | ||
doubleTap: function() { | ||
$(this).text('Double tapped'); | ||
return false; | ||
} | ||
}); | ||
$('#swipeable').on({ | ||
swipeDown: function() { | ||
$(this).text('Swiped down'); | ||
return false; | ||
}, | ||
swipeRight: function() { | ||
$(this).text('Swiped right'); | ||
return false; | ||
} | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo