我的配置:
selenium v 3.13.0 geckodriver 0.21.0 Firefox version 61.0.1
我的应用程序中有以下类型的菜单,我必须将鼠标悬停在类别上,然后必须选择一个产品:
我正在使用 Actions 类来执行操作。使用下面的代码
@QAFTestStep(stepName = "navigateToCategoryProduct", description = "navigate to product name {0} under product category {1}")
public void navigateToCategoryProduct(String product, String category)
throws InterruptedException {
new Actions(getDriver()).moveToElement(getCategory(category)).pause(500)
.moveToElement(getProduct(category, product)).click().build().perform();
}
public QAFWebElement getCategory(String category) {
return new QAFExtendedWebElement(String.format(ConfigurationManager.getBundle()
.getString("header.navigation.category.link"), category));
}
public QAFWebElement getProduct(String category, String product) {
return new QAFExtendedWebElement(String.format(ConfigurationManager.getBundle()
.getString("header.navigation.product.link"), category, product));
}
因此,Chrome 一切顺利(使用 v68.0)。但是虽然在 Firefox 中使用相同的脚本,但它是悬停Food
类别并从Weight Loss
类别中选择产品。我正在挠头寻找如何使该浏览器兼容的替代方法。
我尝试过显式/隐式/硬编码等待,但没有成功。我可以实现悬停并选择子菜单的 Action 类的任何替代方案。