2013-05-22 69 views
1

我正在使用Selenium IDE並嘗試單擊字段中的自動完成項目。我無法找到點擊元素的方法。當您單擊該項目時,它會填充下一個字段。我一直在玩這個爲期兩天,無法弄清楚。如果我可以在該字段中獲得鼠標光標,然後按下然後輸入它可能會工作。我試過:Selenium IDE - 無法在自動完成/無法定位元素中選擇文本

<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> 

但它沒有工作。我曾嘗試使用焦點和/或模糊與sendkeys,keydown和按鍵,但我似乎無法讓它工作。當鼠標懸停在自動完成的單詞上時,也有一個hoverstate。我無法在硒中找到該狀態,也不知道是否需要。任何幫助,將不勝感激。

這是一個鏈接到我試圖點擊,同時被螢火蟲檢查的圖片,以及我在Selenium IDE中嘗試的一些東西。

我也曾嘗試:

對於數值是我應該把「客戶支票跳票」?我可以在字段中獲取文本,但實際上沒有單擊「自動完成」文本,下一個字段將不會填充。這裏是我的嘗試:

<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

感謝, 鮑勃

回答

0

用於typekeys命令硒自動完成命令。 這是一個方便的方法,用於爲指定字符串中的每個字符調用keyDown,keyUp,keyPress;這對於需要顯式按鍵事件的動態UI小部件(如自動完成組合框)非常有用。

typeKeys| css=.ui-corner-all+.ui-corner-all+.ui-corner-all+.ui-corner-all | value 
+0

對於數值是我應該把「客戶支票跳票」?我可以在字段中獲取文本,但實際上沒有單擊「自動完成」文本,下一個字段將不會填充。這是我試過的: 'typeKeys | css = .ui-corner-all + .ui-corner-all + .ui-corner-all + .ui-corner-all |客戶檢查被反彈 – user2348065

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> 
1

我使用硒IDE,並已嘗試選擇從谷歌的地方自動完成生成的元素,下面的腳本正常工作對我來說,我希望這將有助於。

<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