Search code examples
seleniumselenium-rcselenium-ide

Selenium - Unable to click or store a dynamically generated delete id


Im new to selenium and was trying to delete some contacts which i had created earlier.The problem is that the delete link is dynamically generated and im not able to store or click on particular delete link which i want to remove for the list of other delete links for other contacts.

the foll is the code:

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

now if i have added rohit recently to my contacts how im i supposed to catch its id in case i want to delete it from contacts in Selenium.


Solution

  • You can use not only ID for locating your element. For example, you can use:

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

    Or, if you want to find only the first (most recent) delete link:

    link=[delete]
    

    For all locating strategies available in selenium IDE, refer to documentation