Dynamically generated ID Webdriver.

25 views
Skip to first unread message

Kehinde Adeoya

unread,
Jul 2, 2015, 3:07:01 AM7/2/15
to seleniu...@googlegroups.com
A quick response needed please. How do I find a Select / Dropdown element that the ID is dynamically generated? I have tried with the code snippet below but it didn't work. The ID come thus: select2-chosen-3. Only the number digit changes but this "select2-chosen" remains constant.

IWebElement DropDownPath = driver.FindElement(By.CssSelector("select[id*='select2-chosen']"));
SelectElement DropDown = new SelectElement(DropDownPath);
DropDown.SelectByText("Programmer");


Kaleem Uddin Mohammed Abdul

unread,
Jul 12, 2015, 2:39:14 AM7/12/15
to seleniu...@googlegroups.com
I this ID is unique in page the below xpath should work
driver.FindElement(By.Xpath(//select[contains(@id,'select2-chosen')]. Be very careful in providing the id value which is case sensitive.
Reply all
Reply to author
Forward
0 new messages