Selenium 2 WebDriver 实现无法正确处理可扩展菜单
我有一个网页,单击一个按钮(例如 EXPAND_CONTEXT_MENU,内部实现为 href)会导致隐藏的上下文菜单在其下方展开,然后单击上下文菜单中的菜单项。
由于 Selenium 2 不允许直接访问隐藏元素,因此我首先单击 EXPAND_CONTEXT_MENU,然后单击所需的菜单项。
在尝试测试此解决方案时,InternetExplorerDriver 显示出一种奇怪的行为。第一次单击 EXPAND_CONTEXT_MENU 可以正常展开菜单,但在第二次单击(用于选择菜单项)之前,EXPAND_CONTEXT_MENU 会再次最小化。当第二次单击发生时,这会导致 ElementNotVisibleException。
FirefoxDriver 可以很好地执行此测试。我使用IE8和Firefox进行测试。
注意 - 在实际的 AUT 中,只需将鼠标悬停在 EXPAND_CONTEXT_MENU 上即可展开上下文菜单。
I have a web page where clicking on a button (say EXPAND_CONTEXT_MENU, implemented internally as an href) causes a hidden context menu to expand under it, after which I click on of the menu items in the context menu.
Since Selenium 2 does not allow direct access to hidden elements, I first click on EXPAND_CONTEXT_MENU and then click the desired menu item.
While attempting to test this solution, InternetExplorerDriver displays a peculiar behavior. The first click on EXPAND_CONTEXT_MENU expands the menu alright, but before the second click (for selecting the menu item) can occur, EXPAND_CONTEXT_MENU gets minimized again. This results in an ElementNotVisibleException when the second click occurs.
FirefoxDriver performs this test fine. I am using IE8 and Firefox for testing.
Note - in the actual AUT, just a hover on EXPAND_CONTEXT_MENU expands the context menu.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用鼠标功能将鼠标悬停在相关元素上:
您将需要导入 locatable,默认情况下不会引入它:
use the mouse functionality to hover the mouse over the relevant element:
You will need to import locatable, it's not pulled in by default:
可能存在未正确触发的事件绑定。尝试通过 jquery 触发不同的事件(假设 driver 是 WebDriver 实例,element 是您要触发事件的元素):
There is probably an event binding that is not firing correctly. Try firing different events via jquery (assumes that driver is the WebDriver instance and that element is the element you want to fire the event on):