悬停在一秒后消失 [英] Hover Disappear after one sec

查看:187
本文介绍了悬停在一秒后消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好



我试图将鼠标悬停在网站菜单上并点击其内部链接(仅在悬停其可见后)



但问题是当我将鼠标悬停在菜单上时,它只显示一秒钟,它在Internet Explorer WebDriver中发生,在其他网站中都可以正常工作
它可以是什么? / p>

我尝试的内容:




  • 点击菜单 driver.FindElement(By.XPath( // DIV [@ ID = '菜单'] / UL /锂[2]))点击(); //异常:元素不可点击。



我的代码是:

 行动动作=新行动(司机); 
IWebElement menuHoverLink = driver.FindElement(By.XPath(// div [@ id ='Menu'] / ul / li [2]));
actions.MoveToElement(menuHoverLink);
actions.Build()。Perform(); //< - 出现一秒钟并关闭
actions.Click(); //< - 什么都不做

driver.FindElement(By.Id(inMenuLink))。Click(); //例外:元素不可见


解决方案

看起来像这样一个InternetExplorerDriver的已知问题。



根据 InternetExplorerDriver的官方文档


悬停在元素上



当您尝试将鼠标悬停在元素上,并且您的物理鼠标
光标位于IE浏览器窗口的边界内时,悬停
将无效。更具体地说,悬停似乎适用于
分数秒,然后该元素将恢复到其
之前的状态
。发生这种情况的流行理论是IE在事件循环期间进行了某种类型的命中测试,这导致
在物理光标为
时响应物理鼠标位置窗口界限。 WebDriver开发团队已经无法发现IE的这种行为的


如上所述,你应该尝试将物理鼠标光标移出IE窗口边界,然后尝试执行你的代码。



希望这会有所帮助。


Hello

I trying to hover on website menu and click it's inside link (only after hover its visible)

but the problem is when i hover on the menu its only visible for a second, its happening in Internet Explorer WebDriver, in other sites all working fine what can it be ?

What i Tried:

  • Click on menu driver.FindElement(By.XPath("//div[@id='Menu']/ul/li[2]")).Click(); // Exception: element not clickable .

my code is:

Actions actions = new Actions(driver);
IWebElement menuHoverLink = driver.FindElement(By.XPath("//div[@id='Menu']/ul/li[2]"));
actions.MoveToElement(menuHoverLink);
actions.Build().Perform(); // <- appear for a sec and closed
actions.Click(); // <- doing nothing 

driver.FindElement(By.Id("inMenuLink")).Click(); // Exception: element not visible

解决方案

Looks like this a known issue with the InternetExplorerDriver.

As per the official documentation of InternetExplorerDriver

Hovering Over Elements

When you attempt to hover over elements, and your physical mouse cursor is within the boundaries of the IE browser window, the hover will not work. More specifically, the hover will appear to work for a fraction of a second, and then the element will revert back to its previous state. The prevailing theory why this occurs is that IE is doing hit-testing of some sort during its event loop, which causes it to respond to the physical mouse position when the physical cursor is within the window bounds. The WebDriver development team has been unable to discover a workaround for this behavior of IE.

As mentioned in above issue, you should try to move your physical mouse cursor out of the IE window boundries, and then try to execute your code.

Hope this helps.

这篇关于悬停在一秒后消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆