【发布时间】:2018-10-22 00:55:24
【问题描述】:
我正在尝试在 React 应用上测试一个简单的拖放行为。
我正在使用react-dnd-treeview 库和their example website 来测试我的测试用例。
当我在调试中运行测试时,我没有收到任何错误,而且 Selenium 能够获得正确的元素,但什么也没发生,我无法创建或可视化任何类型的操作,即使在尝试之后也是如此这么多不同的答案in this similar question,但都是徒劳的。
这是我正在使用的代码:
package tests;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import java.io.File;
public class DAndDJava {
public static void main(String[] args) {
File file = new File("C:/misc/chromedriver.exe");
System.setProperty("webdriver.chrome.driver" , file.getAbsolutePath());
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("http://teleport.github.io/react-dnd-treeview/example/dist/index.html");
WebElement dragPoint = driver.findElement(By.xpath ("//*[@id=\"root\"]/div/div/div[3]/div[2]/div[2]/div/div/div[3]/div[2]/div/div[1]/div[3]/div[1]/div"));
WebElement dropPoint = driver.findElement(By.xpath ("//*[@id=\"root\"]/div/div/div[3]/div[2]/div[2]/div/div/div[3]/div[2]/div/div[1]/div[3]/div[1]"));
Actions builder = new Actions(driver);
Action dragAndDrop = builder.clickAndHold(dragPoint)
.moveToElement(dropPoint)
.release(dropPoint)
.build();
dragAndDrop.perform();
driver.quit();
}
}
【问题讨论】:
标签: java selenium selenium-webdriver drag-and-drop