Hi I am facing problem to identify cause @id is dynamic :-

//div[@id='SubmissionWizard:LOBWizardStepGroup:LineWizardStepSet:WC7LineCoverageScreen:WC7LineCoverageCV:WC7ConditionsDV:5:CoverageInputSet:ConditionInputGroup:PolicyOwnerOfficerLV-body']//tr[RowIndex]//td[ColIndex+5]/div[@class='x-grid-cell-inner ']

In the above @id is


In second attempt @id is


I cannot use contains also because similarity is there, so I need to handle this numbers before coverageInputSet.

  • 2
    Can you provide the html?
    – saifur
    Commented Mar 1, 2015 at 15:44

2 Answers 2


If it's just a counter (or another single value) that changes, track it as a variable in your test method and concatinate it.

driver.findElement(By.Xpath("fixed path" + counter + "fixed path 2"));

If that's not enough, check this thread for some other tricks. It's basically the same question as yours.


If this is your ID, it is not good for testing anyways. If you cannot use contains, you have to drop the use of ID here and switch to classes and structure. Ask the programmers for test support and let them add meaningful semantic classes.

Not the answer you're looking for? Browse other questions tagged or ask your own question.