I'm trying to capture the id of an element that will be randomly generated. I can successfully capture the value of my element id like this...
| storeAttribute | //div[1]@id | variableName |
Now my variable will be something like...
divElement-12345
I want to remove 'divElement-' so that the variable I am left with is '12345' so that I can use it later to select the 'form-12345' element associated with it...something like this:
| type | //tr[@id='form-${variableName}']/td/form/fieldset/p[1]/input | Type this |
How might I be able to accomplish this?
You have two options in Selenium, XPath and CSS Selector. I have read that CSS Selector is better for doing tests in both FireFox and IE. Using the latest version of Selenium IDE (3/5/2009) I've had success with using storeEval which evaluates Javascript expressions, giving you access to javascript string functions.
XPath:
storeAttribute | //div[1]@id | divID
storeEval | '${divID}'.replace("divElement-", "") | number
type | //tr[@id='form-${number}']/td/form/fieldset/p[1]/input | Type this
CSS Selector:
storeAttribute | css=div[1]@id | divID
storeEval | '${divID}'.replace("divElement-", "") | number
type | css=tr[id='form-${number}'] > td > form > fieldset > p[1] > input | Type this