Hi I am using Selenium RC in Eclipse and JUnit , how i capture dynamic id , Please answer me soon
A:
To make them static isn't always possible for particular project(framework used).
You may deal with developers, that they provide rules for ID prefixes or postfixes.
And then check correspondingly with XPATH selectors and regexp.
sergionni
2010-02-04 11:45:29
a framework that doesn't allow static (or predictable) ids for meaningful components should be dropped immediately.
Bozho
2010-02-04 11:47:07
at least they, may try do IDs predictable
sergionni
2010-02-04 11:49:13
Bozho,i haven't seen, you said "predictable", so agree with you
sergionni
2010-02-04 11:50:19
@Bozho - so you suggest people shouldn't use Dojo and ExtJS? They create dynamic ids on components but can easily be caught and worked against
AutomatedTester
2010-02-04 15:55:11
don't they allow you to assign ids? JSF generates ids as well, but it gives you the option to give them yourself.
Bozho
2010-02-04 15:59:08
@Bozho - When you are working something that generates a lot of things before its rendered you don't always know the ID and since IDs need to be unique you need to make sure that there is no chance of overlap. So if you have 2 people called Bohzo in a list on the page and to edit their accounts you need a unique identifier.Not always doable.
AutomatedTester
2010-02-04 16:09:03
I said static or _predictable_. Complex components (RichFaces for example) generate a lot of other elements. But their IDs are predictable. Like `mycomponentid_header`. Or if there are multiple elements inside they are named `mycomplnentid:1:item`, `mycomponentid:2:item` and so on.
Bozho
2010-02-04 16:13:44
+3
A:
To use work against dynamic IDs you need to either use CSS selectors or XPath.
For xpath you would have xpath=//input[@contains(@id,'partOfId')]
to find an input where you know part of the ID or for css it would be css=input[id^='partOfId']
AutomatedTester
2010-02-04 15:59:47