在要点击的元素可用之前,需要将鼠标悬停在菜单上!
Selenium上的 Element is not currently visible and so may not be interacted with (WARNING: The server did not provide any stacktrace information)
错误
我试过这个:
action.moveToElement(WebElement1);
action.moveToElement(WebElement2);
action.click();
action.perform();
答案 0 :(得分:0)
在类似的情况下,使用DriverBackedSelenium-click和JSExecutor的组合为我工作。请参阅这些链接,了解如何使用它们。
http://docs.seleniumhq.org/docs/03_webdriver.jsp#using-javascript
答案 1 :(得分:0)
此代码对我有用:
private Actions builder;
builder = new Actions(driver);
builder.moveToElement(Elel).build().perform();
答案 2 :(得分:0)
尝试下面的内容,
Actions actions = new Actions(driver);
Action action1 = actions.moveToElement(webElement1).build();
action1.perform();
Action action2 = actions.moveToElement(webElement2).click().build();
action2.perform();
答案 3 :(得分:0)
要解决您在评论中提供的问题,请点击“关于我们”菜单中的“职业”链接,尝试以下操作:
Actions action = new Actions(driver);
action.moveToElement(driver.findElement(By.id("nav5")).moveToElement(driver.findElement(By.linkText("Careers")).click().build().perform();
显然,如果您想要点击鼠标悬停操作后出现的其他链接,您只需要更改相关的element
定位器。