如何在Selenium中进行拖放动作?
build().perform()执行所有步骤。示例
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.Action;
import org.openqa.selenium.interactions.Actions;
import java.util.concurrent.TimeUnit;
public class DrgAndDrp{
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
String url = " https://jqueryui.com/draggable/v";
driver.get(url);
driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS);
driver.switchTo().frame(0);
WebElement source= driver.findElement(By.id("draggable"));
WebElement target= driver.findElement(By.id("droppable"));
// dragAndDrop() method for dragging the element from source to //destination
Actions a = new Actions(driver);
Thread.sleep(5000);
a.dragAndDrop(source, target).build().perform();
Thread.sleep(5000);
driver.quit();
}
}热门推荐
6 保研的祝福语简短
10 年轻20岁祝福语简短
11 朋友结婚祝福语信息简短
12 女孩婚礼贺卡祝福语简短
13 30段点歌简短祝福语
14 虎年春节祝福语图文简短
15 写给后妈祝福语大全简短
16 简短回复生日祝福语
17 校长送毕业祝福语简短
18 毕业立体贺卡祝福语简短