-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Open
twalpole
wants to merge
6
commits into
teamcapybara:master
Choose a base branch
from
twalpole:touch
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Touch API #1289
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9a22ea7
Touch API and tests
twalpole 3dcc300
fix suacelabs env vars
twalpole e7ce0d4
encrypt saucelabs keys for jnicklas/capybara
twalpole a679442
only run the touch tests on travis if the secure env vars are available
twalpole d7c3bf3
swipe - need to document - do we need to keep flick?
twalpole 58aab76
typo
twalpole File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It should be uncommented. I think you commented it because Android driver doesn't support
long_press
currenly (https://github.com/appium/appium/blob/463e692c7bb7c38dc1a95319aaa6c95ba986bed7/lib/devices/android/android-controller.js#L1042)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.
Yes, it's commented because it didn't work, so I manually did the long press with a delay