Java 如何在selenium中测试鼠标移动到按钮时弹出的文本

Java 如何在selenium中测试鼠标移动到按钮时弹出的文本,java,selenium-webdriver,Java,Selenium Webdriver,当鼠标移动到按钮中时,弹出文本显示为“投资列表” 如何使用selenium测试此问题请尝试以下代码: public void testSuccess() throws InterruptedException { System.out.println("test arribute popup"); Thread.sleep(3000); WebElement searchBtn = driver.findElement(By.xpath(".//*[@id='inve

当鼠标移动到按钮中时,弹出文本显示为“投资列表” 如何使用selenium测试此问题请尝试以下代码:

 public void testSuccess() throws InterruptedException {
    System.out.println("test arribute popup");
    Thread.sleep(3000);

    WebElement searchBtn = driver.findElement(By.xpath(".//*[@id='investedList']/span/span[2]/span"));


    Actions action = new Actions(driver);
    action.moveToElement(searchBtn).perform();
    Thread.sleep(3000);

}

您是否尝试了方法
.Gettext()?首先捕获该文本的元素定位器。然后使用getText()函数读取文本。您是如何尝试的,您能分享代码吗?我想你需要先切换到弹出窗口。
List<WebElement> overlaysTooltips = driver.findElements(By.xpath(".//*[@id='investedList']/span/span[2]/span"));

for(int i = 0; i < overlaysTooltips.size(); i++){

    Actions builder = new Actions(driver);  
    builder.moveToElement(overlaysTooltips.get(i)).perform();       

    //get button text after hover
    if((overlaysTooltips.get(i).getAttribute("value").equals("//ur button hover string")){
                //ur condition
                Thread.sleep(3000);
            }
    }
overlaysTooltips.get(i).getAttribute("id")
or
overlaysTooltips.get(i).getAttribute("class")
or
overlaysTooltips.get(i).getAttribute("name")