问题描述
我正在为以下拖放功能编写演示测试.[请参阅附加的屏幕截图]为此,我编写了以下代码:
I am writing demo tests for the following drag and drop functionality.[Refer attached Screenshot]For that I have written following code:
@Test
public void DragAndDropTest() {
commonSteps();
WebElement drag = driver.findElement(By.xpath("html/body/div[1]/div[3]/div[2]/div[1]/div[4]/div[3]/div[1]/div[1]/div/div[1]"));
WebElement drop = driver.findElement(By.xpath("html/body/div[1]/div[3]/div[2]/div[1]/div[4]/div[3]/div[1]/div[2]/div/div[1]"));
Actions builder = new Actions(driver);
Action dragAndDrop = builder.clickAndHold(drag).moveToElement(drop).release(drop).build();
dragAndDrop.perform();
}
Webelement拖动用于立即"和"WebElement放置用于快速按下".
Webelement drag is for "Right Now" & WebElement drop is for "Quick Press".
我的代码能够找到这些元素,但是无法将立即创建"框架拖放到快速按下"框架.
My code is able to find these elements, but does not drag and drop "Right Now" frame to "Quick Press" frame.
我也尝试单击拖动,但单击也不起作用.我认为这些是可折叠的JQuery拖放面板.因此,如何使用webdriver处理可折叠的拖放操作.
Also I tried to click on drag, but click is also not working on it. I think these are collapsible drag and drop panels of JQuery. So How to handle collapsible drag and drops using webdriver.
我应该对代码进行哪些更改以实现此目的?
What changes should I make in the code to achieve this?
推荐答案
Actions builder = new Actions(driver);
builder.clickAndHold(drag).moveToElement(drop).build();
builder.dragAndDrop(drag, drop).perform();
这对我有用.
这篇关于无法使用Selenium-Webdriver将元素拖放到另一个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!