# frozen_string_literal: true
# Licensed to the Software Freedom Conservancy (SFC) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The SFC licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# This file is automatically generated. Any changes will be lost!
module Selenium
module DevTools
module V138
class Input
EVENTS = {
drag_intercepted: 'dragIntercepted',
}.freeze
def initialize(devtools)
@devtools = devtools
end
def on(event, &block)
event = EVENTS[event] if event.is_a?(Symbol)
@devtools.callbacks["Input.#{event}"] << block
end
def dispatch_drag_event(type:, x:, y:, data:, modifiers: nil)
@devtools.send_cmd('Input.dispatchDragEvent',
type: type,
x: x,
y: y,
data: data,
modifiers: modifiers)
end
def dispatch_key_event(type:, modifiers: nil, timestamp: nil, text: nil, unmodified_text: nil, key_identifier: nil, code: nil, key: nil, windows_virtual_key_code: nil, native_virtual_key_code: nil, auto_repeat: nil, is_keypad: nil, is_system_key: nil, location: nil, commands: nil)
@devtools.send_cmd('Input.dispatchKeyEvent',
type: type,
modifiers: modifiers,
timestamp: timestamp,
text: text,
unmodifiedText: unmodified_text,
keyIdentifier: key_identifier,
code: code,
key: key,
windowsVirtualKeyCode: windows_virtual_key_code,
nativeVirtualKeyCode: native_virtual_key_code,
autoRepeat: auto_repeat,
isKeypad: is_keypad,
isSystemKey: is_system_key,
location: location,
commands: commands)
end
def insert_text(text:)
@devtools.send_cmd('Input.insertText',
text: text)
end
def ime_set_composition(text:, selection_start:, selection_end:, replacement_start: nil, replacement_end: nil)
@devtools.send_cmd('Input.imeSetComposition',
text: text,
selectionStart: selection_start,
selectionEnd: selection_end,
replacementStart: replacement_start,
replacementEnd: replacement_end)
end
def dispatch_mouse_event(type:, x:, y:, modifiers: nil, timestamp: nil, button: nil, buttons: nil, click_count: nil, force: nil, tangential_pressure: nil, tilt_x: nil, tilt_y: nil, twist: nil, delta_x: nil, delta_y: nil, pointer_type: nil)
@devtools.send_cmd('Input.dispatchMouseEvent',
type: type,
x: x,
y: y,
modifiers: modifiers,
timestamp: timestamp,
button: button,
buttons: buttons,
clickCount: click_count,
force: force,
tangentialPressure: tangential_pressure,
tiltX: tilt_x,
tiltY: tilt_y,
twist: twist,
deltaX: delta_x,
deltaY: delta_y,
pointerType: pointer_type)
end
def dispatch_touch_event(type:, touch_points:, modifiers: nil, timestamp: nil)
@devtools.send_cmd('Input.dispatchTouchEvent',
type: type,
touchPoints: touch_points,
modifiers: modifiers,
timestamp: timestamp)
end
def cancel_dragging
@devtools.send_cmd('Input.cancelDragging')
end
def emulate_touch_from_mouse_event(type:, x:, y:, button:, timestamp: nil, delta_x: nil, delta_y: nil, modifiers: nil, click_count: nil)
@devtools.send_cmd('Input.emulateTouchFromMouseEvent',
type: type,
x: x,
y: y,
button: button,
timestamp: timestamp,
deltaX: delta_x,
deltaY: delta_y,
modifiers: modifiers,
clickCount: click_count)
end
def set_ignore_input_events(ignore:)
@devtools.send_cmd('Input.setIgnoreInputEvents',
ignore: ignore)
end
def set_intercept_drags(enabled:)
@devtools.send_cmd('Input.setInterceptDrags',
enabled: enabled)
end
def synthesize_pinch_gesture(x:, y:, scale_factor:, relative_speed: nil, gesture_source_type: nil)
@devtools.send_cmd('Input.synthesizePinchGesture',
x: x,
y: y,
scaleFactor: scale_factor,
relativeSpeed: relative_speed,
gestureSourceType: gesture_source_type)
end
def synthesize_scroll_gesture(x:, y:, x_distance: nil, y_distance: nil, x_overscroll: nil, y_overscroll: nil, prevent_fling: nil, speed: nil, gesture_source_type: nil, repeat_count: nil, repeat_delay_ms: nil, interaction_marker_name: nil)
@devtools.send_cmd('Input.synthesizeScrollGesture',
x: x,
y: y,
xDistance: x_distance,
yDistance: y_distance,
xOverscroll: x_overscroll,
yOverscroll: y_overscroll,
preventFling: prevent_fling,
speed: speed,
gestureSourceType: gesture_source_type,
repeatCount: repeat_count,
repeatDelayMs: repeat_delay_ms,
interactionMarkerName: interaction_marker_name)
end
def synthesize_tap_gesture(x:, y:, duration: nil, tap_count: nil, gesture_source_type: nil)
@devtools.send_cmd('Input.synthesizeTapGesture',
x: x,
y: y,
duration: duration,
tapCount: tap_count,
gestureSourceType: gesture_source_type)
end
end # Input
end # V138
end # DevTools
end # Selenium