Selenium and changing elements

My application under test has a very nice feature. When a page loads, 3 listboxes are shown and at least 4 input fields. When the last lisbox is changed, it triggers some code. The remaining input fields are changed to listboxes. Ofcourse these new Listboxes have the same ID as the Input fields.

The first problem I encouterd is what happens exactly. With Selenium I got several error messages that did not give me a clue of what had happened. There was a message that the specified field was an Input instead of a Select. Another was that the element was not available any more.

I tried to solve it by trying to wait for the select element, but that didn’t work because the Input field had the same ID as the Select. The name property was not filled in. Then I added a check if the specified field was of the class Select. At first it did not work, but after seperating them it did. Below is the code:

int a = 0;
while(a == 0) {
if(driver.findElement( ).getTagName().equalsIgnoreCase("select")) {
a = 1;

while(ExpectedConditions.presenceOfElementLocated( ) == null ) {

For now this works, but if you have a better idea, please do not hesitate to contact me. Also I have only tested this with Internet Explorer 10.

After thinking this over (again), I changed the order. First wait until you find a SELECT, then wait if it is visible.

Selenium and changing elements