Skip to content

Commit

Permalink
chore: use ::Selenium::WebDriver::Interactions.pointer as example (#352)
Browse files Browse the repository at this point in the history
* chore: use ::Selenium::WebDriver::Interactions.pointer as example

* update comment
  • Loading branch information
KazuCocoa authored Nov 1, 2021
1 parent a77a6eb commit 5ad23bc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions lib/appium_lib_core/common/base/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -800,15 +800,15 @@ def multi_touch(actions)
#
# @example: Zoom
#
# f1 = @driver.action.add_pointer_input(:touch, 'finger1')
# f1 = ::Selenium::WebDriver::Interactions.pointer(:touch, name: 'finger1')
# f1.create_pointer_move(duration: 1, x: 200, y: 500,
# origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
# f1.create_pointer_down(:left)
# f1.create_pointer_move(duration: 1, x: 200, y: 200,
# origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
# f1.create_pointer_up(:left)
#
# f2 = @driver.action.add_pointer_input(:touch, 'finger2')
# f2 = ::Selenium::WebDriver::Interactions.pointer(:touch, name: 'finger2')
# f2.create_pointer_move(duration: 1, x: 200, y: 500,
# origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
# f2.create_pointer_down(:left)
Expand All @@ -821,6 +821,10 @@ def multi_touch(actions)
def perform_actions(data)
raise ::Appium::Core::Error::ArgumentError, "'#{data}' must be Array" unless data.is_a? Array

# NOTE: 'add_input' in Selenium Ruby implementation has additional 'pause'.
# This implementation is to avoid the additional pause.
# https://github.com/SeleniumHQ/selenium/blob/64447d4b03f6986337d1ca8d8b6476653570bcc1/rb/lib/selenium/webdriver/common/action_builder.rb#L207

@bridge.send_actions data.map(&:encode).compact
data.each(&:clear_actions)
nil
Expand Down
4 changes: 2 additions & 2 deletions test/functional/android/webdriver/w3c_actions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def _uiautomator2_do_actions_with_many_down_up(element, rect)
def test_multiple_actions
skip_as_appium_version '1.8.0'

f1 = @driver.action.add_pointer_input(:touch, 'finger1')
f1 = ::Selenium::WebDriver::Interactions.pointer(:touch, name: 'finger1')
f1.create_pointer_move(duration: 1, x: 200, y: 500,
origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
f1.create_pointer_down(:left)
Expand All @@ -169,7 +169,7 @@ def test_multiple_actions
origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
f1.create_pointer_up(:left)

f2 = @driver.action.add_pointer_input(:touch, 'finger2')
f2 = ::Selenium::WebDriver::Interactions.pointer(:touch, name: 'finger2')
f2.create_pointer_move(duration: 1, x: 200, y: 500,
origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
f2.create_pointer_down(:left)
Expand Down
4 changes: 2 additions & 2 deletions test/unit/android/webdriver/w3c/actions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_w3c__multiple_actions
.with(body: action_body.to_json)
.to_return(headers: HEADER, status: 200, body: { value: nil }.to_json)

f1 = @driver.action.add_pointer_input(:touch, 'finger1')
f1 = ::Selenium::WebDriver::Interactions.pointer(:touch, name: 'finger1')
f1.create_pointer_move(duration: 0.05, x: 100, y: 100,
origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
f1.create_pointer_down(:left)
Expand All @@ -153,7 +153,7 @@ def test_w3c__multiple_actions
origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
f1.create_pointer_up(:left)

f2 = @driver.action.add_pointer_input(:touch, 'finger2')
f2 = ::Selenium::WebDriver::Interactions.pointer(:touch, name: 'finger2')
f2.create_pointer_move(duration: 0.05, x: 100, y: 100,
origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
f2.create_pointer_down(:left)
Expand Down

0 comments on commit 5ad23bc

Please sign in to comment.