【问题标题】:Unable to find the sub menu element which disappears when mouse pointer is moved outside the menu frame无法找到当鼠标指针移到菜单框外时消失的子菜单元素
【发布时间】:2014-03-27 18:47:31
【问题描述】:

我的代码是:

driver.findElement(By.xpath(".//*[@id='fmf-name-title-cellsort-label']")).click(); // Main menu item
driver.findElement(By.xpath("//*[@id='quick-filter-input']")).sendKeys("Profile1121"); // Sub menu item

在上面的代码中:

移动移出子菜单项消失,找不到元素“@id='quick-filter-input”

错误显示:

org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"//*[@id='quick-filter-input']"}
Command duration or timeout: 10.02 seconds

点击主菜单时出现子菜单。

谁能帮帮我,如何找到所需的 subMenu 元素?

【问题讨论】:

    标签: java selenium-webdriver submenu


    【解决方案1】:

    要使用仅在悬停时出现的下拉菜单,您必须使用:

    Actions actions = new Actions(driver);
    actions.moveToElement(driver.findElement(menu)); //this makes your submenu appear
    actions.moveToElement(driver.findElement(submenu)).click().perform(); //this click your submenu or you can do whatever action you want with it
    

    【讨论】:

      猜你喜欢
      • 2013-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-27
      • 2014-02-08
      • 1970-01-01
      • 2016-03-15
      • 2017-05-10
      相关资源
      最近更新 更多