You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Firefox中Selenium Actions二次调用失效问题求助

Firefox下重复调用Actions悬停函数失败的问题

测试时两次调用同一包含Actions操作的函数,首次执行正常且测试用例通过,但第二次在Firefox中无法正确触发悬停动作;程序误判动作已完成,导致后续依赖步骤失败。该代码在Chrome中运行正常,仅在Firefox中异常。

相关代码如下:

private Actions actions = new Actions(driver);

@FindBy(css = "div.o-dropdown:nth-child(3)")
public WebElement myAccountBtn;

public void hoverProfileGoToManageProfiles() {
   WebElement topNavBar = driver.findElement(By.cssSelector(".c-navbar__container"));
   wait.until(ExpectedConditions.invisibilityOf(loadingSpinner));
   wait.until(ExpectedConditions.elementToBeClickable(topNavBar));
   performHoverManageProfiles();
}

public void performHoverManageProfiles() {
   actions.moveToElement(myAccountBtn).perform();
   WebElement manageProfilesBtn = driver.findElement(By.xpath("//*[@id=\"app\"]/nav[1]/div/div[2]/div[1]/div[2]/div/a[1]"));
   WebElement clickableManageProfilesBtn = wait.until(ExpectedConditions.elementToBeClickable(manageProfilesBtn));
   clickableManageProfilesBtn.click();
}

注:performHoverManageProfiles()中的manageProfilesBtn需在悬停动作完成后才能找到。

已尝试的方案:

  • 将WebElement创建移入函数
  • 重置myAccountBtn
  • 添加Thread.sleep()
  • 增加显式等待

以上方案均未解决问题。

内容的提问来源于stack exchange,提问作者Akaime

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 11:35:13