我正在尝试从一个非常知名的网站单击一些 JQUERY 元素来练习 Selenium(http://the-internet.herokuapp.com/jqueryui/menu)。
我想出了如何导航到菜单(不确定我的代码是否是一个好的解决方案),但是我无法单击每个最后一个子菜单选项(PDF、CSV、Excel)
我正在尝试如下所示:
Actions builder = new Actions(driver);
Action mouseOverMenu;
mouseOverMenu = builder.moveToElement(driver.findElement(By.id("ui-id-2"))).build();
mouseOverMenu.perform(); //accessing Enabled menu option
mouseOverMenu = builder.moveToElement(driver.findElement(By.id("ui-id-4"))).build();
mouseOverMenu.perform(); //accessing Downloads submenu option
String jQuerySelector = "$('a#ui-id-6.ui-corner-all')";
WebElement webElement = (WebElement) ((JavascriptExecutor) driver).executeScript("return $(" + jQuerySelector+ ").get(0);");
//click() also did not work
WebElement webElement = (WebElement) ((JavascriptExecutor) driver).executeScript("return $(" + jQuerySelector+ ").click();");
ITMISS
相关分类