Dan. Thank you very much! I tested it about 8 times in chrome and firefox
and it worked perfectly. I can't say much of a relief it is to know the
way to handle these since I have to test dozens of web forms that have a
series of select lists that filter down based on the previous selection.
No more sleep command!
However, I did have an error a couple times saying "An open modal dialog
blocked the operation", but I'm fairly certain that this is more of an
issue with the way the form calls the json data.
I think your logic is spot on, but I'll post back to this topic if I have
any issues.
On Thursday, October 4, 2012 7:06:21 PM UTC-5, Dan wrote:
>
> If the options in the drop down are being set dynamically, then you need
> to approach this differently. The select may be present, but the option in
> that select probably isn't at the same time if the data is being populated
> dynamically. You probably need to do something like this instead.
>
> browser.select(:id, "degree_code").wait_until_present
> # Even though the select is there, its options might not be populated yet.
> Watir::Wait.until{browser.select(:id,
> "degree_code").include?("Bachelor's")}
> browser.select(:id, "degree_code").select("Bachelor's")
>
> On Thursday, October 4, 2012 5:27:18 PM UTC-4, MjHerz wrote:
>>
>> I am trying to eliminate my "sleep" commands, but so far the "sleep" is
>> more consistent than "wait_until_present". Can someone check the attached
>> screenshot to see the simple select list scenario and compare to the couple
>> lines of Ruby/Watir script that I have below?
>>
>> I have several web forms that call json data in order to determine which
>> items will appear in the next select list, so depending on how fast that
>> service is, I need to have the script select the value only after it is
>> present. This method seems to be exactly what I need, but I'm just not
>> able to get it to work consistently.
>>
>> Below are a couple lines of code specific to the two select lists:
>> Again, the choice made in the first select list will impact the options
>> that will be available. In this case, "Bachelor's" degree code should make
>> "Business Management" available in the study_area_code select list. I'm
>> trying to follow examples on http://watirwebdriver.com/waiting/.
>>
>> browser.select(:id, "degree_code").wait_until_present
>> browser.select(:id, "degree_code").select("Bachelor's")
>>
>> browser.select(:id, "study_area_code").wait_until_present
>> browser.select(:id, "study_area_code").select("Business Management")
>>
>>
>> I get this error message, so does anyone know what I could change? I've
>> already tried this variation with => instead of a comma:
>> #browser.select(:id => "study_area_code").wait_until_present
>>
>> Your help would be greatly appreciated.
>>
>> /Users/mherzog/.rvm/gems/ruby-1.9.3-p194/gems/watir-webdriver-0.6.1/lib/watir-webdriver/elements/select.rb:216:in
>>
>> `no_value_found': "Business Management" not found in select list
>> (Watir::Exception::NoValueFoundException)
>> from
>> /Users/mherzog/.rvm/gems/ruby-1.9.3-p194/gems/watir-webdriver-0.6.1/lib/watir-webdriver/elements/select.rb:150:in
>>
>> `rescue in select_by_string'
>> from
>> /Users/mherzog/.rvm/gems/ruby-1.9.3-p194/gems/watir-webdriver-0.6.1/lib/watir-webdriver/elements/select.rb:147:in
>>
>> `select_by_string'
>> from
>> /Users/mherzog/.rvm/gems/ruby-1.9.3-p194/gems/watir-webdriver-0.6.1/lib/watir-webdriver/elements/select.rb:129:in
>>
>> `select_by'
>> from
>> /Users/mherzog/.rvm/gems/ruby-1.9.3-p194/gems/watir-webdriver-0.6.1/lib/watir-webdriver/elements/select.rb:64:in
>>
>> `select'
>> from
>> /Users/mherzog/Documents/MBS/Ruby/Web_Forms/QA/LandingPages/IRF_redesign1.rb:16:in
>>
>> `<main>'
>> [Finished in 10.5s with exit code 1]
>>
>>
>>
>>
>>
>>
>>
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]