ruby - Selecting Options one by one Using watir-webdriver- -


b.select_list(:id, "maincontent_drpvehicletype").when_present.options.each |option|     option.select      b.select_list(:id, "maincontent_drpmake").when_present.options.each |option|         option.select          b.select_list(:id, "maincontent_drpmodel").when_present.options.each |option|             option.select              b.button(:id,"maincontent_imgbtnsearch").click         end     end end 

i'm having 3 dropdown each dropdown depends on previous values have select each option 1 one , click button . *while doing getting following error* element no longer attached dom (selenium::webdriver::error::staleelementreferenceerror)

also tried:

 b.driver.manage.timeouts.implicit_wait = 3 

assuming each option unique, try:

  1. get last option in dependent list
  2. make selection in current list
  3. wait option in step 1 no longer appear

the following implements idea (though has not been tested since not have similar page test against):

b.select_list(:id, "maincontent_drpvehicletype").when_present.options.each |option|      #select vehicle type , wait last make option no longer appear     last_make_option = b.select_list(:id, "maincontent_drpmake").when_present.options.last     option.select     last_make_option.wait_while_present      b.select_list(:id, "maincontent_drpmake").when_present.options.each |option|          #select make , wait last model option no longer appear         last_model_option = b.select_list(:id, "maincontent_drpmodel").when_present.options.last         option.select         last_model_option.wait_while_present          b.select_list(:id, "maincontent_drpmodel").when_present.options.each |option|             option.select              b.button(:id,"maincontent_imgbtnsearch").click         end     end end 

note that:

  • the code assumes last option of dependent list change. if not true, might need check against options of dependent list.

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -