0
我寫了下面的代碼,但沒有找到元素。該網站的鏈接是http://plugnedit.com/。在Selenium WebDriver中拖放操作的問題
我已經嘗試過各種方法來定位頁面上的元素來嘗試拖動對象。它不工作。獲取「無法定位元素」錯誤。
我正在使用firefox。
謝謝。
driver.navigate().to("http://plugnedit.com/");
Actions dragAndDrop = new Actions(driver);
WebElement itemToDrag = driver.findElement(By.id("p1003upperspan"));
// drag downwards
int numberOfPixelsToDragTheScrollbarDown = 10;
for (int i=10;i<150;i=i+numberOfPixelsToDragTheScrollbarDown){
// this causes a gradual drag of the scroll bar, 10 units at a time
dragAndDrop.moveToElement(itemToDrag).clickAndHold().moveByOffset(0,numberOfPixelsToDragTheScrollbarDown).release().perform();
}