Selenium - DragAndDrop在Mac Os Hi Sierra上无法在Safari 12.1上运行

问题描述 投票:0回答:1

我试图在Safari 12.1上拖放一个对象在Mac Os Hi Sierra上。

它拖动对象,移动到指定位置,但不释放对象。

我执行了下面提到的代码行,但它们都具有相同的效果:

actionTest.dragAndDropBy(dragMe,
xCoOrdinate,yCoOrdinate).build().perform();

actionTest.dragAndDropBy(dragMe,
xCoOrdinate,yCoOrdinate).release().build().perform();

如果我需要设置任何浏览器功能,请建议。

使用的测试URL是:https://www.bryntum.com/examples/scheduler/animations/

java selenium selenium-webdriver safari
1个回答
0
投票

拖放语法。 Actions类有两个支持Drag and Drop的方法。让我们研究一下 -

Actions.dragAndDrop(Sourcelocator, Destinationlocator)

在某些应用程序中,我们可能会面临自动将项目从一个位置拖放到另一个位置的情况。我们无法使用基本元素来实现这些目标。 Selenium提供了一个“Actions”类来处理这种场景。我们克服了这种情况,例如使用Actions Class进行拖放。

Action Class in Selenium

在dragAndDrop方法中,我们传递了两个参数 -

第一个参数“Sourcelocator”是我们需要拖动的元素。

第二个参数“Destinationlocator”是我们需要删除第一个元素的元素

Actions.dragAndDropBy(Sourcelocator, x-axis pixel of Destinationlocator, y-axis pixel of Destinationlocator)

dragAndDropBy方法我们传递了3个参数 -

  1. 第一个参数“Sourcelocator”是我们需要拖动的元素。
  2. 第二个参数是我们需要删除第一个元素的第二个元素的x轴像素值。
  3. 第三个参数是我们需要删除第一个元素的第二个元素的y轴像素值。

您还可以从this网站获得更多信息。

试试这个:-

    WebDriver driver= new FirefoxDriver();
    driver.get("https://www.bryntum.com/examples/scheduler/animations/");
    //driver.get("https://demoqa.com/droppable/");
    WebElement From=driver.findElement(By.xpath("//*[@id=\"b-scheduler-8-1-1-x\"]/div"));   

    WebElement To=driver.findElement(By.xpath("//*[@id=\"b-subgrid-14\"]/div[2]/div")); 
    Actions act=new Actions(driver);                    

    //Dragged and dropped.      
         act.dragAndDrop(From, To).build().perform();   

希望它对你有用..

并且没有这样的元素通过qazxsw poi链接。

© www.soinside.com 2019 - 2024. All rights reserved.