I need to add date value into text field for date picker, but I can't find text field element because value for ID (date_f2672867e99141c491f00f20ee45f6d8_I) is still different.

Here is a code for text field:

<td class="dxic" onmousedown="return aspxDDMC_MD('date_f2672867e99141c491f00f20ee45f6d8', event)" style="width:100%;"> <input id="date_f2672867e99141c491f00f20ee45f6d8_I" class="dxeEditArea_MetalogixMetropolisBlue dxeEditAreaSys" name="date_f2672867e99141c491f00f20ee45f6d8" onfocus="aspxEGotFocus('date_f2672867e99141c491f00f20ee45f6d8')" onblur="aspxELostFocus('date_f2672867e99141c491f00f20ee45f6d8')" onchange="aspxETextChanged('date_f2672867e99141c491f00f20ee45f6d8')" autocomplete="off" type="text"/> </td>

And class="dxic" is on the web page more times. I can't use class name to find element.

I want to add into text field value e.g.: 5/31/2017

Can anyone provide an example how to add value into this text field ?

1 Answer 1


I can't give exact code, but I can give you some suggestions.

If this is the only input on the form with a name and id that starts with the text 'date_' you can use Linq syntax to find the field you want (this is psuedo-code - I don't have time to look up the exact references):

driver.findElements(By.TagName("input")).Where(el -> el.getAttribute("name").contains("date_")).Single();

Or broken out a bit more:

elements = driver.findElements(By.TagName("input")); // collection of all input elements on the page
dateInput = elements.Where(el -> el.getAttribute("name").contains("date_")).Single();
// Linq syntax - el -> el.GetAttribute() is pulling information from the attributes of each element in the list. The name attribute is probably the easiest one to look at.
// Each name attribute value is a string, so the String.contains() method can be used on it.
// Finally, if there's just one input element on the page that has a name starting with "date_", .Single() returns that one element from the collection.

Once you've got the element, you can set the value to whatever you wish.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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