Selenium - 无法单击或存储动态生成的删除ID

时间:2012-03-21 10:44:43

标签: selenium selenium-rc selenium-ide

我是selenium的新手并试图删除我之前创建的一些联系人。问题是删除链接是动态生成的,我无法存储或点击我要删除的特定删除链接列表其他联系人的其他删除链接。

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: rohit@gmail.com
<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: chupudi@gmai.com
<br>
Phone: 12345678
<br>
</div>

现在,如果我最近已将rohit添加到我的联系人中,我是否应该抓住其ID,以防我想从Selenium中的联系人中删除它。

2 个答案:

答案 0 :(得分:0)

捕获要删除的动态ID 您可以使用以下命令:

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

现在您拥有该元素的动态ID。使用该值单击它。

click| ${variableName}

答案 1 :(得分:0)

您不仅可以使用ID来查找元素。例如,您可以使用:

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

或者,如果您只想查找第一个(最近的)删除链接:

link=[delete]

有关selenium IDE中提供的所有定位策略,请参阅documentation