Path: blob/trunk/rb/lib/selenium/webdriver/common/interactions/pointer_move.rb
1990 views
# frozen_string_literal: true12# Licensed to the Software Freedom Conservancy (SFC) under one3# or more contributor license agreements. See the NOTICE file4# distributed with this work for additional information5# regarding copyright ownership. The SFC licenses this file6# to you under the Apache License, Version 2.0 (the7# "License"); you may not use this file except in compliance8# with the License. You may obtain a copy of the License at9#10# http://www.apache.org/licenses/LICENSE-2.011#12# Unless required by applicable law or agreed to in writing,13# software distributed under the License is distributed on an14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15# KIND, either express or implied. See the License for the16# specific language governing permissions and limitations17# under the License.1819module Selenium20module WebDriver21module Interactions22#23# Action related to moving the pointer.24#25# @api private26#2728class PointerMove < Interaction29include PointerEventProperties3031VIEWPORT = :viewport32POINTER = :pointer33ORIGINS = [VIEWPORT, POINTER].freeze3435def initialize(source, duration, x, y, **opts)36super(source)37@duration = duration * 100038@x_offset = x39@y_offset = y40@origin = opts.delete(:element) || opts.delete(:origin) || :viewport41@type = :pointerMove42@opts = opts43end4445def assert_source(source)46raise TypeError, "#{source.type} is not a valid input type" unless source.is_a? PointerInput47end4849def encode50process_opts.merge('type' => type.to_s,51'duration' => @duration.to_i,52'x' => @x_offset,53'y' => @y_offset,54'origin' => @origin)55end56end # PointerMove57end # Interactions58end # WebDriver59end # Selenium606162