Selenium鼠标左击,右击,双击,悬停

public static void mouseActions(String mouseActions){
    if(null != drivers){
        try {
            Thread.sleep(2000);
        }catch (InterruptedException ine){ine.printStackTrace();}
        Actions actions = new Actions(drivers);
        actions.moveToElement(drivers.findElement(By.xpath(mouseActions))).perform();
        //actions.doubleClick(drivers.findElement(By.xpath(mouseActions))).perform();//双击操作
        //actions.contextClick(drivers.findElement(By.xpath(mouseActions))).perform();//右击操作
        //actions.click(drivers.findElement(By.xpath(mouseActions))).perform();//单击操作传入参数,并且使用perform()提交,生效
    }
}

猜你喜欢

转载自blog.csdn.net/dubo_csdn/article/details/82888484