@@ -497,36 +497,10 @@ def fill_in_address(field, app, session, lists):
497497 with app .collect_operations () as ops :
498498 fields ['country_button' ].click ()
499499
500-
501- # Write PSC instead of city name (TODO: hack to work with current AIS)
502- fields ['city' ].write (city_psc )
503- with app .collect_operations () as ops :
504- fields ['city_button' ].click ()
505-
506- if len (ops ) == 1 and ops [- 1 ].method == 'openDialog' :
507- # Open selection dialogue
508- select_dlg = app .awaited_open_dialog (ops )
509-
510- rows = app .d .table .all_rows ()
511-
512- # Let's try to find the correct row by checking the PSC
513- row_index = None
514- for idx , row in enumerate (rows ):
515- print ('city_psc: {}, row_value: {}' .format (city_psc , row .cells [2 ].value ), file = sys .stderr )
516- if row .cells [2 ].value == city_psc :
517- row_index = idx
518-
519- # If we did find a row, let's select it
520- if row_index is not None :
521- app .d .table .select (row_index )
522- #else:
523- # raise Exception('Could not find city_psc {}'.format(city_psc))
524-
525- with app .collect_operations () as ops :
526- app .d .enterButton .click ()
527-
528- # Close selection dialogue
529- select_dlg = app .awaited_close_dialog (ops )
500+ select_city_by_psc_ciselnik_code (app ,
501+ city_psc ,
502+ session [field ]['city' ],
503+ fields ['city' ], fields ['city_button' ])
530504
531505 # TODO: hack to work with current AIS
532506 # Write the actual city to "Post office" field
@@ -771,6 +745,9 @@ def select_city_by_psc_ciselnik_code(app, city_psc, ciselnik_code, city_field, c
771745 with app .collect_operations () as ops :
772746 city_button .click ()
773747
748+ if len (ops ) == 0 :
749+ return
750+
774751 if len (ops ) == 1 and ops [- 1 ].method == 'openDialog' :
775752 # Open selection dialogue
776753 select_dlg = app .awaited_open_dialog (ops )
0 commit comments