"Fossies" - the Fresh Open Source Software Archive

Member "selenium-selenium-4.8.1/dotnet/src/webdriverbackedselenium/Internal/SeleniumEmulation/DragAndDrop.cs" (17 Feb 2023, 2594 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C# source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "DragAndDrop.cs" see the Fossies "Dox" file reference documentation.

    1 // <copyright file="DragAndDrop.cs" company="WebDriver Committers">
    2 // Licensed to the Software Freedom Conservancy (SFC) under one
    3 // or more contributor license agreements. See the NOTICE file
    4 // distributed with this work for additional information
    5 // regarding copyright ownership. The SFC licenses this file
    6 // to you under the Apache License, Version 2.0 (the "License");
    7 // you may not use this file except in compliance with the License.
    8 // You may obtain a copy of the License at
    9 //
   10 //     http://www.apache.org/licenses/LICENSE-2.0
   11 //
   12 // Unless required by applicable law or agreed to in writing, software
   13 // distributed under the License is distributed on an "AS IS" BASIS,
   14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   15 // See the License for the specific language governing permissions and
   16 // limitations under the License.
   17 // </copyright>
   18 
   19 using System;
   20 using System.Globalization;
   21 using OpenQA.Selenium;
   22 using OpenQA.Selenium.Interactions;
   23 
   24 namespace Selenium.Internal.SeleniumEmulation
   25 {
   26     /// <summary>
   27     /// Defines the command for the dragAndDrop keyword.
   28     /// </summary>
   29     internal class DragAndDrop : SeleneseCommand
   30     {
   31         private ElementFinder finder;
   32 
   33         /// <summary>
   34         /// Initializes a new instance of the <see cref="DragAndDrop"/> class.
   35         /// </summary>
   36         /// <param name="elementFinder">An <see cref="ElementFinder"/> used to find the element on which to execute the command.</param>
   37         public DragAndDrop(ElementFinder elementFinder)
   38         {
   39             this.finder = elementFinder;
   40         }
   41 
   42         /// <summary>
   43         /// Handles the command.
   44         /// </summary>
   45         /// <param name="driver">The driver used to execute the command.</param>
   46         /// <param name="locator">The first parameter to the command.</param>
   47         /// <param name="value">The second parameter to the command.</param>
   48         /// <returns>The result of the command.</returns>
   49         protected override object HandleSeleneseCommand(IWebDriver driver, string locator, string value)
   50         {
   51             string[] parts = value.Split(new string[] { "," }, 2, StringSplitOptions.None);
   52             int deltaX = int.Parse(parts[0], CultureInfo.InvariantCulture);
   53             int deltaY = int.Parse(parts[1], CultureInfo.InvariantCulture);
   54 
   55             IWebElement element = this.finder.FindElement(driver, locator);
   56             Actions actionBuilder = new Actions(driver);
   57             actionBuilder.DragAndDropToOffset(element, deltaX, deltaY).Perform();
   58 
   59             return null;
   60         }
   61     }
   62 }