我尝试获取鼠标悬停操作后出现的元素。怎么办?
我试过了:
Actions action = new Actions(driver);
action.moveToElement(elem);
action.perform();
WebElement myDynamicElement = (new WebDriverWait(driver,10)).until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("class*='hoverEverywhereTooltip'")));
此元素出现在鼠标悬停事件之后。
答案 0 :(得分:0)
试试这个。
代码:
Actions actions = new Actions(driver);
WebElement menuhover = driver.findElement(By.linkText("Menu"));
actions.moveToElement(menuhover);
WebElement subLink = driver.findElement(By.id("submenu"));
actions.moveToElement(submenu);
actions.click();
actions.perform();
答案 1 :(得分:0)
它有效我在cssSelector
属性中错过了 [] :
WebElement myDynamicElement =(new WebDriverWait(driver,10))。until(ExpectedConditions.presenceOfElementLocated(By.c ssSelector(“[class * ='hoverEverywhereTooltip']”)));