For a Drupal site, I have written a test script in Selenium IDE that logs in as the administrator, adds a new user and peforms a series of tests on the registration page.
Once this user has been added, I would like to add to this script so that it then goes to the user panel, and removes it again. Getting to the user admin page is simple, and I have the username field stored from earlier, say "test user 2".
In the user admin panel, we have this:
What I need to do is find a way to select the checkbox next to the appropriate user. The problem is that the checkbox is marked up as such:
<input type="checkbox" class="form-checkbox" value="4" id="edit-accounts-4" name="accounts[4]">
Now, as mentioned before, the only information I have about the user is the username. Unfortunately the id of the checkbox references the internal user id, which is 4. That's information I don't have. However, the username link I can locate because I have the value stored. I can just locate any anchor element containing the username string "test user 2". Markup is:
<a title="View user profile." href="/user/4">test user 2</a>
Since I have "test user 2" as the username already stored, I can select this element in my test case. But what I want to do is select the checkbox next to it. There's two ways that I think this can be done:
1) Extract the number "4" from the href attribute and use that to select the checkbox, since all checkbox ids will be of the form "edit-accounts-x" where x is a number.
2) Use some funky xpath to determine that the checkbox is on the same row as the username I have stored.
Thoughts?