2012-03-21 62 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