1

I am using Selenium IDE and trying to click an autocomplete item in a field. I am unable to find a way to click the element. When you click the item it populates the next field. I have been playing around with this for two days and cannot figure it out. If I could get the mouse cursor in the field, then press down followed by enter it would probably work. I tried:

<td>clickAt</td>
<td>id=txtCategory</td>
<td></td>

<td>keyPress</td>
<td>css=.ui-corner-all+.ui-corner-all+.ui-corner-all+.ui-corner-all</td>
<td>\40</td>

<td>keyPress</td>
<td>css=.ui-corner-all+.ui-corner-all+.ui-corner-all+.ui-corner-all</td>
<td>\13</td>

but it didn't work. I have tried using focus and/or blur with sendkeys, keydown, and keypress but I couldn't seem to get that to work either. There is also a hoverstate when you mouseover the autocomplete word. I couldn't find a way to access that state in selenium nor do I know if I need to. Any help would be appreciated.

Here is a link to the picture of the field I am trying to click while being inspected by firebug, along with a few of the things i was trying in Selenium IDE.

I have also tried:

For Value was I supposed to put 'Customer check bounced'? I can get the text in the field but without actually clicking the Autocompleted text the next field will not populate. Here is what I tried:

<td>typeKeys</td>
<td>css=.ui-corner-all+.ui-corner-all+.ui-corner-all+.ui-corner-all</td>
<td>Customer check bounced</td>



<td>fireEvent</td>
<td>css=.ui-corner-all+.ui-corner-all+.ui-corner-all+.ui-corner-all</td>
<td>focus</td>



<td>fireEvent</td>
<td>css=.ui-corner-all+.ui-corner-all+.ui-corner-all+.ui-corner-all</td>
<td>blur</td>


<td>keyPress</td>
<td>css=.ui-corner-all+.ui-corner-all+.ui-corner-all+.ui-corner-all</td>
<td>\13</td>

enter image description here

Thanks, Bob

4

3 回答 3

1

经过 2 天的搜索,我找到了解决问题的方法。您可以使用 html 找到项目并单击它们。以下是我使用的步骤:

1. Click into the field to cause the autocomplete to fire

<td>clickAt</td>
<td>id=txtCategory</td>
<td></td>

2. Mouseover the field that contains the autocompleted word I need to click

<td>mouseOver</td>
<td>//html/body/ul/li/a/b</td>
<td></td>

3. Click the autocomplete item I need to click in order for the next field to function

<td>click</td>
<td>//html/body/ul/li/a/</td>
<td></td>
于 2013-05-24T14:08:19.370 回答
1

我正在使用 Selenium IDE 并一直在尝试选择从 google place 自动完成生成的元素,以下脚本对我来说很好,我希望它会有所帮助。

<tr>
    <td>sendKeys</td>
    <td>id=address</td>
    <td>48 Westlawn Dr.</td>
</tr>
<tr>
    <td>keyDown</td>
    <td>id=address</td>
    <td>\40</td>
</tr>
<tr>
    <td>keyDown</td>
    <td>id=address</td>
    <td>\13</td>
</tr>
  1. sendKeys将触发下拉菜单
  2. keyDown在选择之间跳转
  3. 最后keyDown是发送回车键

诀窍是对同一元素执行的所有操作。

参考: http: //www.software-testing-tutorials-automation.com/2013/06/selenium-keydown-command-to-select.html

于 2017-04-24T23:57:00.810 回答
0

在 selenium 中使用 typekeys 命令进行自动完成命令。这是为指定字符串中的每个字符调用 keyDown、keyUp、keyPress 的便捷方法;这对于需要显式键事件的动态 UI 小部件(如自动完成组合框)很有用。

typeKeys| css=.ui-corner-all+.ui-corner-all+.ui-corner-all+.ui-corner-all | value
于 2013-05-23T09:11:48.070 回答