@@ -131,7 +131,7 @@ public String getTextField(String fieldLabel)
131131 {
132132 WebElement fieldValueElement = elementCache ().valueCellWithLabel (fieldLabel );
133133 WebElement textElement = fieldValueElement .findElement (By .xpath ("./div/div/*" ));
134- if (textElement .getTagName ().equalsIgnoreCase ("textarea" ))
134+ if (textElement .getTagName ().equalsIgnoreCase ("textarea" ))
135135 return textElement .getText ();
136136 else
137137 return textElement .getAttribute ("value" );
@@ -146,14 +146,14 @@ public String getTextField(String fieldLabel)
146146 **/
147147 public DetailTableEdit setTextField (String fieldLabel , String value )
148148 {
149- if (isFieldEditable (fieldLabel ))
149+ if (isFieldEditable (fieldLabel ))
150150 {
151151 WebElement fieldValueElement = elementCache ().valueCellWithLabel (fieldLabel );
152152
153153 WebElement editableElement = fieldValueElement .findElement (By .xpath ("./div/div/*" ));
154154 String elementType = editableElement .getTagName ().toLowerCase ().trim ();
155155
156- switch (elementType )
156+ switch (elementType )
157157 {
158158 case "textarea" :
159159 case "input" :
@@ -291,6 +291,11 @@ public boolean isFileFieldBlank(String fieldLabel)
291291 .hasAttachedFile ();
292292 }
293293
294+ public FilteringReactSelect getSelectField (String fieldLabel )
295+ {
296+ return elementCache ().findSelect (fieldLabel );
297+ }
298+
294299 /**
295300 * Get the value of a select field.
296301 *
@@ -299,17 +304,18 @@ public boolean isFileFieldBlank(String fieldLabel)
299304 **/
300305 public String getSelectedValue (String fieldLabel )
301306 {
302- FilteringReactSelect reactSelect = elementCache ().findSelect (fieldLabel );
303- return reactSelect .getValue ();
307+ return getSelectField (fieldLabel ).getValue ();
304308 }
305309
306- /*
307- This allows you to query a given select in the edit panel to see what options it offers
308- */
310+ /**
311+ * This allows you to query a given select in the edit panel to see what options it offers.
312+ *
313+ * @param fieldLabel The label of the field to get.
314+ * @return List of strings for the values in the list.
315+ **/
309316 public List <String > getSelectOptions (String fieldLabel )
310317 {
311- FilteringReactSelect reactSelect = elementCache ().findSelect (fieldLabel );
312- return reactSelect .getOptions ();
318+ return getSelectField (fieldLabel ).getOptions ();
313319 }
314320
315321 /**
@@ -333,7 +339,6 @@ public DetailTableEdit createSelectValue(String fieldLabel, String value)
333339 return this ;
334340 }
335341
336-
337342 /**
338343 * Select multiple values from a select list.
339344 *
@@ -343,7 +348,7 @@ public DetailTableEdit createSelectValue(String fieldLabel, String value)
343348 **/
344349 public DetailTableEdit setSelectValue (String fieldLabel , List <String > selectValues )
345350 {
346- FilteringReactSelect reactSelect = elementCache (). findSelect (fieldLabel );
351+ FilteringReactSelect reactSelect = getSelectField (fieldLabel );
347352 selectValues .forEach (reactSelect ::typeAheadSelect );
348353 _changeCounter ++;
349354 return this ;
@@ -361,24 +366,25 @@ public DetailTableEdit clearSelectValue(String fieldLabel)
361366 }
362367
363368 /**
364- * Clear a given select field
369+ * Clear a given select field.
370+ *
365371 * @param fieldLabel The label of the field to clear.
366372 * @param waitForSelection If true, wait for the select to have a selection before clearing it
367373 * @param assertSelection If true, assert if no selection appears (note: does nothing if waitForSelection is not true)
368- * @return
374+ * @return A reference to this editable detail table.
369375 */
370376 public DetailTableEdit clearSelectValue (String fieldLabel , boolean waitForSelection , boolean assertSelection )
371377 {
372- var select = elementCache (). findSelect (fieldLabel );
378+ var select = getSelectField (fieldLabel );
373379 if (waitForSelection )
374380 {
375- if (assertSelection ) {
376- WebDriverWrapper .waitFor (() -> select .hasSelection (),
381+ if (assertSelection )
382+ {
383+ WebDriverWrapper .waitFor (select ::hasSelection ,
377384 String .format ("The %s select did not have any selection in time" , fieldLabel ), _readyTimeout );
378385 }
379- else {
380- WebDriverWrapper .waitFor (() -> select .hasSelection (), 1000 );
381- }
386+ else
387+ WebDriverWrapper .waitFor (select ::hasSelection , 1_000 );
382388 }
383389 select .clearSelection ();
384390 _changeCounter ++;
@@ -398,19 +404,19 @@ public DetailTableEdit clearSelectValue(String fieldLabel, boolean waitForSelect
398404 public DetailTableEdit setDateTimeField (String fieldName , Object dateTime )
399405 {
400406 ReactDateTimePicker dateTimePicker = getDateTimePicker (fieldName );
401- if (dateTime instanceof LocalDateTime localDateTime )
407+ if (dateTime instanceof LocalDateTime localDateTime )
402408 {
403409 dateTimePicker .select (localDateTime );
404410 }
405- else if (dateTime instanceof LocalDate localDate )
411+ else if (dateTime instanceof LocalDate localDate )
406412 {
407413 dateTimePicker .selectDate (localDate );
408414 }
409- else if (dateTime instanceof LocalTime localTime )
415+ else if (dateTime instanceof LocalTime localTime )
410416 {
411417 dateTimePicker .selectTime (localTime );
412418 }
413- else if (dateTime instanceof String setValue )
419+ else if (dateTime instanceof String setValue )
414420 {
415421 dateTimePicker .set (setValue , true );
416422 }
@@ -481,7 +487,7 @@ private String getSourceTitle()
481487 */
482488 public String getValidationMessage ()
483489 {
484- if (elementCache ().validationMsg .existsIn (this ))
490+ if (elementCache ().validationMsg .existsIn (this ))
485491 return elementCache ().validationMsg .findElement (getDriver ()).getText ();
486492 else
487493 return "" ;
@@ -534,8 +540,7 @@ public String clickSaveExpectingError()
534540 {
535541 elementCache ().saveButton .click ();
536542 WebElement errorBanner = BootstrapLocators .errorBanner .findWhenNeeded (this );
537- WebDriverWrapper .waitFor (()->errorBanner .isDisplayed (),
538- "No error message was shown." , 1_000 );
543+ WebDriverWrapper .waitFor (errorBanner ::isDisplayed , "No error message was shown." , 1_000 );
539544 return errorBanner .getText ();
540545 }
541546
@@ -550,8 +555,7 @@ public String clickCancelExpectingError()
550555 {
551556 elementCache ().cancelButton .click ();
552557 WebElement errorBanner = BootstrapLocators .errorBanner .findWhenNeeded (this );
553- WebDriverWrapper .waitFor (()->errorBanner .isDisplayed (),
554- "No error message was shown." , 1_000 );
558+ WebDriverWrapper .waitFor (errorBanner ::isDisplayed , "No error message was shown." , 1_000 );
555559 return errorBanner .getText ();
556560 }
557561
@@ -647,5 +651,4 @@ protected Locator locator()
647651 return _locator ;
648652 }
649653 }
650-
651654}
0 commit comments