1

我正在使用 Firefox WebDriver 来测试 Web 应用程序。Web 应用程序有一个顶部导航栏,当您将鼠标悬停在它上面时,一些元素会下拉到菜单中。

我想在悬停后单击下拉菜单中的按钮。我正在执行以下代码:

    WebElement dropDown = driver.findElement(By
            .xpath("html/body/header/div/ul/li[6]/span[2]/a"));
    WebElement logoutButton = driver.findElement(By
            .xpath("html/body/header/div/ul/li[6]/ul/li[2]/a"));

    //build and perform the mouseOver with Advanced User Interactions API
    Actions builder = new Actions(driver);    
    builder.moveToElement(dropDown).perform();

    Thread.sleep(1000);

    logoutButton.click();

但我收到以下错误:

Element is not currently visible and so may not be interacted with

你知道我怎样才能让这个下拉按钮可见吗?我可以做些什么来完成这项工作吗?

- - - 更多细节 - - -

但是,在睡眠期间,浏览器在屏幕左下角显示 URL 信息,表明 Web 驱动程序实际上是悬停的,但按钮不可见。

4

0 回答 0