Now i have such watir code:
require "watir-webdriver"
browser = Watir::Browser.new :ff
browser.driver.manage.timeouts.implicit_wait = 3 #3 seconds
browser.goto "https://page***/default.aspx"
browser.select_list(:name => 'ctl00$tresc$cbListaKrajow').select_value('6')
puts "Selected country"
browser.select_list(:name => 'ctl00$tresc$cbListaPlacowek').wait_until_present
browser.select_list(:name => 'ctl00$tresc$cbListaPlacowek').select_value('95')
puts "Selected city"
But main trouble is that ctl00$tresc$cbListaPlacowek is loading it’s options only via
ctl00$tresc$cbListaKrajow is changed. It could take 1 or 30 seconds so `browser.driver.manage.timeouts.implicit_wait = 3 #3 seconds` is not a good idea. How can i write that it try to select option unless it is present? Now i get errors like it could find such option...
Note that you could have also done:
Just a little nicer to write.
Update:
If you want to wait for any option to appear in the select list you can do:
This is technically waiting for a first option to appear. Note that depending on what you are doing, this could give you false positives. For example, if the select list is already populated with options, you trigger some event to re-populate the list, the select list would already have a first option. In this case, you might have to also check that the list of options has changed.
If you want to select an option with a value that matches any in an array, you could do: