How to identify elements if the id/name/class name are generated randomly?

Add Comment
3 Answer(s)

Use Xpath.

driver.findElements(By.xpath(“//*[contains(text(),’Some String’)]”))

jasonw Train Answered on July 22, 2016.
Add Comment

Hi Jason,

Doesn’t work in my case. I’ve a form with multiple dropdowns and all of them have same class and dynamic id’s. I need to click on the dropdown and select a value. List<WebElements> doesn’t work in this case. The application is developed using GWT and Hibernate

<div id=”isc_DC class=”selectItemText tabindex=”4281 style=”width:222px;height:15px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap; $9a=”$9d $89=”isc_SelectItem_23> </div>

Muralidhar Default Answered on July 27, 2016.
Add Comment

If everything is the same you can do the following. This will uniquely define 5 different elements. 


jasonw Train Answered on August 4, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.