Skip to content

Commit 5ad23bc

Browse files
authored
chore: use ::Selenium::WebDriver::Interactions.pointer as example (#352)
* chore: use ::Selenium::WebDriver::Interactions.pointer as example * update comment
1 parent a77a6eb commit 5ad23bc

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

lib/appium_lib_core/common/base/driver.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -800,15 +800,15 @@ def multi_touch(actions)
800800
#
801801
# @example: Zoom
802802
#
803-
# f1 = @driver.action.add_pointer_input(:touch, 'finger1')
803+
# f1 = ::Selenium::WebDriver::Interactions.pointer(:touch, name: 'finger1')
804804
# f1.create_pointer_move(duration: 1, x: 200, y: 500,
805805
# origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
806806
# f1.create_pointer_down(:left)
807807
# f1.create_pointer_move(duration: 1, x: 200, y: 200,
808808
# origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
809809
# f1.create_pointer_up(:left)
810810
#
811-
# f2 = @driver.action.add_pointer_input(:touch, 'finger2')
811+
# f2 = ::Selenium::WebDriver::Interactions.pointer(:touch, name: 'finger2')
812812
# f2.create_pointer_move(duration: 1, x: 200, y: 500,
813813
# origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
814814
# f2.create_pointer_down(:left)
@@ -821,6 +821,10 @@ def multi_touch(actions)
821821
def perform_actions(data)
822822
raise ::Appium::Core::Error::ArgumentError, "'#{data}' must be Array" unless data.is_a? Array
823823

824+
# NOTE: 'add_input' in Selenium Ruby implementation has additional 'pause'.
825+
# This implementation is to avoid the additional pause.
826+
# https://github.com/SeleniumHQ/selenium/blob/64447d4b03f6986337d1ca8d8b6476653570bcc1/rb/lib/selenium/webdriver/common/action_builder.rb#L207
827+
824828
@bridge.send_actions data.map(&:encode).compact
825829
data.each(&:clear_actions)
826830
nil

test/functional/android/webdriver/w3c_actions_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def _uiautomator2_do_actions_with_many_down_up(element, rect)
160160
def test_multiple_actions
161161
skip_as_appium_version '1.8.0'
162162

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

172-
f2 = @driver.action.add_pointer_input(:touch, 'finger2')
172+
f2 = ::Selenium::WebDriver::Interactions.pointer(:touch, name: 'finger2')
173173
f2.create_pointer_move(duration: 1, x: 200, y: 500,
174174
origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
175175
f2.create_pointer_down(:left)

test/unit/android/webdriver/w3c/actions_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def test_w3c__multiple_actions
144144
.with(body: action_body.to_json)
145145
.to_return(headers: HEADER, status: 200, body: { value: nil }.to_json)
146146

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

156-
f2 = @driver.action.add_pointer_input(:touch, 'finger2')
156+
f2 = ::Selenium::WebDriver::Interactions.pointer(:touch, name: 'finger2')
157157
f2.create_pointer_move(duration: 0.05, x: 100, y: 100,
158158
origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
159159
f2.create_pointer_down(:left)

0 commit comments

Comments
 (0)