Selenium 鼠标悬停在IE11和firefox中无法正常工作

Selenium 鼠标悬停在IE11和firefox中无法正常工作,selenium,Selenium,我试图使用Action类将鼠标悬停在一个元素上,然后尝试转到另一个子元素并单击,但我的鼠标悬停指向其他地方 这些是为IE和操作类代码设置的IE功能 InternetExplorerOptions options = new InternetExplorerOptions(); options.enablePersistentHovering(); options.ignoreZoomSettings(); driverinstan

我试图使用Action类将鼠标悬停在一个元素上,然后尝试转到另一个子元素并单击,但我的鼠标悬停指向其他地方

这些是为IE和操作类代码设置的IE功能

InternetExplorerOptions options = new InternetExplorerOptions();                    
options.enablePersistentHovering();             
options.ignoreZoomSettings();
driverinstance = new InternetExplorerDriver(options);

WebDriverWait myWaitVar = new WebDriverWait(driver, const_waithigh);
myWaitVar.until(ExpectedConditions.elementToBeClickable(By.xpath(element1)));
Actions action = new Actions(driver.get());
action.moveToElement(driver.findElement(By.xpath(element1))).click().build().perform();

即使使用
options.ignoreZoomSettings()忽略缩放IE不会计算元素的正确位置,除非应用程序完全最大化并以100%缩放

因此,在初始化IE的驱动程序实例后,请使用以下代码

driver.manage().window().maximize();
driver.findElement(By.tagName('html')).sendKeys(Keys.chord(Keys.CONTROL, "0"));

我们基本上是最大化窗口,并按CTRL+0将其设置为“缩放到默认”级别。看看这是否能解决您的问题。

您能为Firefox提供帮助吗?下面是我的firefox代码,FirefoxOptions FirefoxOptions=newfirefoxoptions();firefoxOptions.setAcceptUnsecureCerts(true);driverinstance=新的FirefoxDriver(firefoxOptions);对于firefox,尝试使用
action.moveToElement(driver.findElement(By.xpath(element1))).build().perform()然后分别单击。详情如下: