本文整理汇总了C#中OpenQA.Selenium.Interactions.Actions.DragAndDropToOffset方法的典型用法代码示例。如果您正苦于以下问题:C# Actions.DragAndDropToOffset方法的具体用法?C# Actions.DragAndDropToOffset怎么用?C# Actions.DragAndDropToOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenQA.Selenium.Interactions.Actions
的用法示例。
在下文中一共展示了Actions.DragAndDropToOffset方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test
public void Test()
{
driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.jpcenter.ru");
driver.FindElement(By.PartialLinkText(make)).Click();
driver.FindElement(By.PartialLinkText(model)).Click();
// Wait for element
driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 45));
// Grab the element and then feed it to the actions statement below.
IWebElement element = driver.FindElement(By.XPath("//div[@id='aj_sl1']/div[2]/img"));
IWebElement element2 = driver.FindElement(By.Id("aj_sl1"));
Actions actionsProvider = new Actions(driver);
actionsProvider.DragAndDropToOffset(element, -100, -100);
actionsProvider.DragAndDropToOffset(element2, -100, -100);
}
示例2: HandleSeleneseCommand
/// <summary>
/// Handles the command.
/// </summary>
/// <param name="driver">The driver used to execute the command.</param>
/// <param name="locator">The first parameter to the command.</param>
/// <param name="value">The second parameter to the command.</param>
/// <returns>The result of the command.</returns>
protected override object HandleSeleneseCommand(IWebDriver driver, string locator, string value)
{
string[] parts = value.Split(new string[] { "," }, 2, StringSplitOptions.None);
int deltaX = int.Parse(parts[0], CultureInfo.InvariantCulture);
int deltaY = int.Parse(parts[1], CultureInfo.InvariantCulture);
IWebElement element = this.finder.FindElement(driver, locator);
Actions actionBuilder = new Actions(driver);
actionBuilder.DragAndDropToOffset(element, deltaX, deltaY).Perform();
return null;
}
示例3: DragSlider
public void DragSlider()
{
// Wait for element
driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 45));
// Grab the element and then feed it to the actions statement below.
IWebElement element = driver.FindElement(By.XPath("//div[@id='aj_sl1']/div[2]/img"));
Console.WriteLine(element.ToString());
Console.ReadLine();
Actions actionsProvider = new Actions(driver);
actionsProvider.DragAndDropToOffset(element, 50, 0);
actionsProvider.ClickAndHold(element);
actionsProvider.MoveByOffset(50, 0);
actionsProvider.Release(element);
}
示例4: MouseActiveLeft
public void MouseActiveLeft(double left, double right, int shift)
{
Actions action = new Actions(Driver);
IWebElement axi = Driver.FindElement(By.Id("axis"));
(Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setRange\"," + left + "," + right + ");");
var before = (Driver as IJavaScriptExecutor).ExecuteScript("return $(\"#axis\").axis(\"getRange\");");
var bL = Convert.ToDouble((before as Dictionary<string, object>)["left"]);
var bR = Convert.ToDouble((before as Dictionary<string, object>)["right"]);
action.Build();
action.DragAndDropToOffset(axi, -shift, 0);
action.Perform();
var after = (Driver as IJavaScriptExecutor).ExecuteScript("return $(\"#axis\").axis(\"getRange\");");
var aL = Convert.ToDouble((after as Dictionary<string, object>)["left"]);
var aR = Convert.ToDouble((after as Dictionary<string, object>)["right"]);
Assert.IsTrue(aL > bL && aR > bR);
}
示例5: DragTooFar
public void DragTooFar()
{
driver.Url = dragAndDropPage;
IWebElement img = driver.FindElement(By.Id("test1"));
// Dragging too far left and up does not move the element. It will be at
// its original location after the drag.
Point originalLocation = new Point(0, 0);
Actions actionProvider = new Actions(driver);
actionProvider.DragAndDropToOffset(img, int.MinValue, int.MinValue).Perform();
Point newLocation = img.Location;
Assert.LessOrEqual(newLocation.X, 0);
Assert.LessOrEqual(newLocation.Y, 0);
// TODO(jimevans): re-enable this test once moveto does not exceed the
// coordinates accepted by the browsers (Firefox in particular). At the
// moment, even though the maximal coordinates are limited, mouseUp
// fails because it cannot get the element at the given coordinates.
//actionProvider.DragAndDropToOffset(img, int.MaxValue, int.MaxValue).Perform();
//We don't know where the img is dragged to , but we know it's not too
//far, otherwise this function will not return for a long long time
}
示例6: drag
private Point drag(IWebElement elem, Point initialLocation, int moveRightBy, int moveDownBy)
{
Point expectedLocation = new Point(initialLocation.X, initialLocation.Y);
expectedLocation.Offset(moveRightBy, moveDownBy);
Actions actionProvider = new Actions(driver);
actionProvider.DragAndDropToOffset(elem, moveRightBy, moveDownBy).Perform();
return expectedLocation;
}
示例7: DragTooFar
public void DragTooFar()
{
driver.Url = dragAndDropPage;
IWebElement img = driver.FindElement(By.Id("test1"));
// Dragging too far left and up does not move the element. It will be at
// its original location after the drag.
Point originalLocation = new Point(0, 0);
Actions actionProvider = new Actions(driver);
actionProvider.DragAndDropToOffset(img, int.MinValue, int.MinValue).Perform();
Assert.AreEqual(originalLocation, img.Location);
actionProvider.DragAndDropToOffset(img, int.MaxValue, int.MaxValue).Perform();
//We don't know where the img is dragged to , but we know it's not too
//far, otherwise this function will not return for a long long time
}
示例8: DragToOffset
public static IWebElement DragToOffset(this IWebElement element, int x, int y)
{
var action = new Actions(WebDriverTestBase.driver);
action.DragAndDropToOffset(element, x, y).Build().Perform();
return element;
}
示例9: DragAndDropOffset
/// <summary>
/// Mousedown event on the element then drag to offset.
/// </summary>
/// <param name="element"></param>
public static void DragAndDropOffset(this IWebElement element, int x, int y)
{
Actions act = new Actions(Browser.Driver);
act.DragAndDropToOffset(element, x, y).Perform();
}