相关疑难解决方法(0)

如何使用Java在Selenium WebDriver中执行鼠标悬停功能?

我想在下拉菜单中执行鼠标悬停功能.当我们将鼠标悬停在菜单上时,它会显示新选项.我尝试使用xpath单击新选项.但无法直接单击菜单.所以,作为我试图将鼠标悬停在下拉菜单上的手动方式,然后将单击新选项.

Actions action = new Actions(webdriver);
WebElement we = webdriver.findElement(By.xpath("//html/body/div[13]/ul/li[4]/a"));
action.moveToElement(we).build().perform();
Run Code Online (Sandbox Code Playgroud)

java selenium mouseover selenium-webdriver

124
推荐指数
6
解决办法
34万
查看次数

如何在Firefox 19中使用Selenium WebDriver进行鼠标悬停?

我用过硒2.31.

我已经使用Actions类进行鼠标移动.使用这个我将鼠标移到一个菜单上,它的子菜单只出现了一小段时间,与旧版本的firefox不同.

由于这个问题我无法选择子菜单,driver.findElement因为它抛出异常"元素无法滚动到视图中".

这有什么解决方案吗?

java mousehover selenium-webdriver

16
推荐指数
1
解决办法
6万
查看次数

如何使用Selenium WebDriver和Java鼠标悬停在webelement上

如何使用Selenium Webdriver执行鼠标悬停功能?

测试用例就像说,打开雅虎网站,并在登录旁边有链接(邮件).鼠标悬停时,它将显示工具提示.

当我尝试下面的代码时,它不是鼠标悬停在确切位置,而是在其他地方徘徊.我哪里错了?

还让我知道,如何捕获工具提示?

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;


public class Sample 
{
    public static void main(String[] args) 
    {
        WebDriver driver=new FirefoxDriver();
        driver.get("http://www.yahoo.com");

        driver.manage().window().maximize();

        try 
                {
            Thread.sleep(5000);
        } catch (InterruptedException e)
                {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        WebElement lMail=driver.findElement(By.xpath("//*[@title='Mail']"));

        Actions builder=new Actions(driver);
        builder.moveToElement(lMail).build().perform();


    }

}
Run Code Online (Sandbox Code Playgroud)

java selenium-webdriver

2
推荐指数
1
解决办法
2万
查看次数