public class Actionss {
public static void main (String[] args) throws InterruptedException {
//驱动配置
System.setProperty("webdriver.chrome.driver","D:\\driver\\chromedriver.exe");
WebDriver driver = new ChromeDriver ();
driver.manage ().window ().maximize ();
driver.get("http://jqueryui.com/resources/demos/droppable/default.html");
Thread.sleep ( 2000 );
//定位元素
WebElement move = driver.findElement ( By.id ("draggable") );
WebElement ele = driver.findElement ( By.id ( "droppable" ) );
//将定位元素拖动到指定处
Actions action =new Actions ( driver );
action.dragAndDrop ( move,ele ).build ().perform ();
assert (driver.findElement ( By.xpath ( "//*[@id='droppable']/p[text()='Dropped!']") ).isDisplayed ()==true);
Thread.sleep (
selenium + java jquery元素——将元素拖动到指定处
最新推荐文章于 2023-06-22 15:51:03 发布