2012-03-21 61 views
0

Im新的硒,並試圖刪除我之前創建的一些聯繫人。問題是,刪除鏈接是動態生成的,我無法存儲或點擊特別是我想刪除其他聯繫人的其他刪除鏈接列表的刪除鏈接。Selenium - 無法點擊或存儲動態生成的刪除ID

的FOLL是代碼:

<h1>Organization Contacts</h1> 
<div id="parent" class="parent_761"> 
<div id="761" class="org_user"> 
rohit sharma 
<div class="contacts"> 
<a id="761" class="edit_contact" title="Click here to edit" href="#">[edit]</a> 
| 
<a title="Click here to delete" rel="nofollow" data-method="delete"  data-confirm="Deleting user will also delete related posts. Are you sure want to remove user "Admin_One TestOrg_One"?" href="/organizations/1075/users/761">[delete]</a> 
    </div> 
    <br> 
    Title: Mr 
    <br> 
    Email: [email protected] 
<br> 
Phone: 1234567890 
<br> 
</div> 
<div id="" class="submit_contactinfo" style="display: none;"> 
</div> 
</div> 
<br> 
<div id="parent" class="parent_772"> 
<div id="772" class="org_user"> 
supreeth rai 
<div class="contacts"> 
<a id="772" class="edit_contact" title="Click here to edit" href="#">[edit]</a> 
| 
<a title="Click here to delete" rel="nofollow" data-method="delete" data-confirm="Deleting user will also delete related posts. Are you sure want to remove "RegularUser3 TestOrg_One" from the Organization?" href="/organizations/1075/users/772">[delete]</a> 
</div> 
<br> 
Title: Mr 
<br> 
Email: [email protected] 
<br> 
Phone: 12345678 
<br> 
</div> 
現在,如果我最近增加羅希特到我的聯繫人我應該如何即時捕捉其ID的情況下,我想在硒的聯繫人刪除

回答

0

您不僅可以使用ID來定位元素。例如,你可以使用:

css=div:contains('rohit') a:contains('delete') 

或者,如果你想找到只有第一個(最近)刪除鏈接:

link=[delete] 

對於硒IDE中所有可用的定位策略,是指documentation

0

爲了趕上動態ID刪除 您可以使用下面的命令:

storeAttribute| path of area where element placed @ id| variableName 

現在你有該元素的動態ID。使用該值來點擊它。

click| ${variableName} 
+0

如果您已經定義了元素放置的區域的路徑,爲什麼要捕獲動態ID? – 2012-06-05 22:57:54