@@ -300,12 +300,11 @@ def user_clicks_on_checkbox(self, page: Page, label: str) -> None:
300300 page .get_by_label (label ).click ()
301301
302302 def user_fills_form_field (
303- self , page : Page , label : str , value : str , index : int = - 1
303+ self , page : Page , label : str , value : str , index : int = 0
304304 ) -> None :
305305 """
306306 Fills the form field with the given value.
307307 If multiple form fields are found, the field at the given index is filled.
308- If no index is provided: the last field is used to accommodate modal forms.
309308 """
310309
311310 # Certain form fields may be shown in a modal that needs some time to load
@@ -314,18 +313,16 @@ def user_fills_form_field(
314313
315314 # Try a (custom) select
316315 selects = page .get_by_role ("combobox" , name = label )
317- _index = index if index > - 1 else selects .count () - 1
318316 if selects .count ():
319- select = selects .nth (_index )
317+ select = selects .nth (index )
320318 select .click ()
321319 option = select .get_by_text (value )
322320 option .click ()
323321 return
324322
325323 # Fill (native) input
326324 inputs = page .get_by_label (label )
327- _index = index if index > - 1 else inputs .count () - 1
328- input = inputs .nth (_index )
325+ input = inputs .nth (index )
329326 input .fill (value )
330327
331328 class Then (GherkinScenario ):
0 commit comments