Esempio n. 1
0
        public void How_To_Automate_Slider()
        {
            IWebElement slider            = chromedriver.FindElement(By.Id("slider"));
            IWebElement sliderEndPosition = chromedriver.FindElement(By.Id("slider"));

            //Oneway
            OpenQA.Selenium.Interactions.Actions action = new OpenQA.Selenium.Interactions.Actions(chromedriver);
            action.DragAndDropToOffset(slider, 30, 30)
            .Build()
            .Perform();

            //Another way
            action.DragAndDrop(slider, sliderEndPosition)
            .Build()
            .Perform();
            //Anotherway(loop by how many times you want to shift)
            slider.SendKeys(Keys.Right);

            //One more way
            action.MoveToElement(slider)
            .ClickAndHold()
            .MoveByOffset(0, 250)
            .Release()
            .Perform();
        }
Esempio n. 2
0
 /// <summary>
 /// Drags the <paramref name="sourceElement"/> to the <paramref name="destinationElement"/>.
 /// </summary>
 /// <param name="sourceElement"></param>
 /// <param name="destinationElement"></param>
 public void DragAndDrop(IWebElement sourceElement, IWebElement destinationElement)
 {
     try
     {
         var builder = new OpenQA.Selenium.Interactions.Actions(driver);
         builder.DragAndDrop(sourceElement, destinationElement);
         builder.Build().Perform();
     } catch (Exception e)
     {
         MyLogger.Log.Error($"Failed to drag source element: {sourceElement} to destination element: {destinationElement}. {e.Message}");
         throw e;
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Метод реализует действие драгндроп от одного элемента до другого
        /// </summary>
        /// <param name="WebItemToDrop">Объект на котором дропаем первый объект</param>
        /// <param name="isAdmin">Признак админки</param>
        /// <param name="ScrollToObject">Скроллить ли до объекта</param>
        public void DragAndDrop(WebItem WebItemToDrop, bool isAdmin = false, bool ScrollToObject = true)
        {
            OpenQA.Selenium.Interactions.Actions builder = new OpenQA.Selenium.Interactions.Actions(BitrixFramework.WebDriver);
            builder.DragAndDrop(BitrixFramework.FindWebElement(this), BitrixFramework.FindWebElement(WebItemToDrop)).Build().Perform();

            Log.MesNormal(String.Format("'{0}' -> Драгндроп до '{1}'", description, WebItemToDrop.description));

            //проверяем страницу на наличие ошибок
            BitrixFramework.CheckJSErrors();
            GM.CheckContentOnErrors();
        }
Esempio n. 4
0
 /// <summary>Holds down the left mouse button on the source element, then moves to the target element and releases the mouse button.</summary>
 /// <param name="webelement_source">The element to mouse down.</param>
 /// <param name="webelement_target">The element to mouse up.</param>
 /// <returns></returns>
 public Actions dragAndDrop(WebElement webelement_source, WebElement webelement_target)
 {
     _actions.DragAndDrop(webelement_source._webElement, webelement_target._webElement);
     return(this);
 }