如何使用Selenium Web驱动程序/Selenium IDE自动执行jQueryUI selectmenu [英] How to automate jQueryUI selectmenu with Selenium web driver/Selenium IDE

查看:83
本文介绍了如何使用Selenium Web驱动程序/Selenium IDE自动执行jQueryUI selectmenu的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力让Selenium从jQueryUI官方插件生成的选择菜单中选择一个选项,如下面更详细的描述,Selenium打开菜单,然后单击以选择一个项目,关闭菜单.菜单,但未选中该选项.

I'm struggling to get Selenium to select an option from a select menu generated by the jQueryUI official plugin, as described in more detail below, Selenium opens the menu, and then goes for the click to select an item, closes the menu, but the option is not selected.

设置的一些背景:

  • 使用Selenium IDE Firefox插件
  • 使用jQueryUI SelectMenu演示页面进行测试 (因此,我们可以确保每个人都可以访问该代码段,并避免将select菜单至少作为其演示站点进行了适当的实现)
  • Using Selenium IDE Firefox Plugin
  • Using the jQueryUI SelectMenu Demo page to test on (So we can ensure the code snippet is one everyone can access, and eliminate that the selectmenu is at least properly implemented, as its their demo site)

测试源: http://jqueryui.com/selectmenu/

我尝试将硒单击作为span.ui-selectmenu文本的目标,然后单击ID = ui-id-5的元素,没有运气.然后,我尝试单击span.speed-button,然后选择选项.也没有运气.

I have tried targeting the span.ui-selectmenu-text for the selenium click, and then clicking the element with ID=ui-id-5, no luck. I then tried clicking on span.speed-button, and then select the option. Also no luck.

在所有情况下,菜单都会打开和关闭,但仍会选择原始值.

In all cases, the menu opens, and closes, but the original value is still selected.

但是,发生了一件奇怪的事情.在Selenium IDE中,如果执行以下操作,则将其选中:

However, a weird thing happens. In the Selenium IDE, if I do the following, then it IS selected:

  1. 双击命令"以打开菜单.
  2. 双击命令"以选择正确的ID元素.
  3. 再次双击命令以选择正确的ID元素.

现在,所选的选项突然被更新.但是,当我端到端运行脚本时,单击两次Commands,它将再次失败,并且仅在页面上选择了默认选项.

Suddenly now, the selected option is updated. But when I run a script end to end, with the two click Commands, it fails again, and just has the default option selected on the page.

代码:

<tr>
    <td>open</td>
    <td>/selectmenu/</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>css=span.ui-selectmenu-text</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>id=ui-id-5</td>
    <td></td>
</tr>

如果有人可以向我指出正确的方向,任何提示或提示或实际解决问题的方法,那将是很好的.

If someone could point me in the right direction, any tips or hints, or an actual solution to the problem, that would be great.

我在发布此消息之前就进行了搜索,但我唯一能找到的是3年前的解决方案了,不再可用了:

I DID search SO before posting this, but the only one I could find was from 3 years ago, and the solution did not work anymore:

如何使用ui selectmenu进行测试( jQuery)和硒

推荐答案

我实际上终于找到了解决这个问题的简单方法.首先在元素上使用mouseOver,然后单击它.问题解决了.

I actually finally found a really simple answer to this problem. You use mouseOver on the element first, THEN you click it. Problem solved.

希望有帮助.

保罗,在您花时间编写该答案时,为了公平起见,我将由选民选择接受的答案".感谢您的贡献.

Paul, as you spent time writing that answer, to be fair to you, I'll leave it up to voters to choose the "accepted answer". Thanks for your contribution.

这篇关于如何使用Selenium Web驱动程序/Selenium IDE自动执行jQueryUI selectmenu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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