public void type ( String text ) { String action = "Typing text '" + text + IN + prettyOutput ( ) ; String expected = prettyOutputStart ( ) + " is present, displayed, and enabled to have text " + text + " typed in" ; boolean warning = false ; try { if ( isNotPresentEnabledInput ( action , expected ) ) { return ; } if ( ! is . displayed ( ) ) { warning = true ; } WebElement webElement = getWebElement ( ) ; webElement . sendKeys ( text ) ; } catch ( Exception e ) { log . warn ( e ) ; reporter . fail ( action , expected , CANT_TYPE + prettyOutputEnd ( ) + e . getMessage ( ) ) ; return ; } if ( warning ) { reporter . check ( action , expected , TYPED + text + IN + prettyOutput ( ) + ". <b>THIS ELEMENT WAS NOT DISPLAYED. THIS MIGHT BE AN ISSUE.</b>" ) ; } else { reporter . pass ( action , expected , TYPED + text + IN + prettyOutputEnd ( ) . trim ( ) ) ; } }
Type the supplied text into the element but only if the element is present enabled and an input . If those conditions are not met the type action will be logged but skipped and the test will continue . If the element is not displayed a warning will be written in the log to indicate this is not a normal action as could be performed by the user .