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()提交,生效 } }