Population of select lists are often linked to the values of other entries on a page. Here is an example where the first field (text field) entry is used to do a search which populates the second field (select list) on hitting ‘Enter’. Selection of an option from that list populates the third field (also a select list).

before entries

This is all done with javascript, so Watir doesn’t know when the select lists are ready. Depending on network and database latency, I could only rely on a long (10+ second) sleep to catch each select field fully ready. With long tests and searches like this that are used quite often, 15-20 seconds a pop can add up.

I did some investigation with this code:

with this output (in irb):

which obviously indicated the select list went away.

I tried this:

with this output:

Lo and behold! In this particular application the select list exists for a second unpopulated, then goes away for a bit, returning populated! As the borrower id is a full name string I could tell that the select list was populated when the select field size increased.

after hit enter
Selecting a borrower name automatically triggered a similar (but not quite the same) effect for the Loan number select list:

after selection

Because this functionality is used on several pages in the application under test I put together a method that looks like this to get the options from the first list:

and after confirming the options contained the desired borrower name used code like this:

Now there is no wasted time waiting unnecessarily and the process of getting to the desired loan is much more reliable.

watir