public void selectFrame ( ) { String cantSelect = "Unable to focus on frame " ; String action = "Focusing on frame " + prettyOutput ( ) ; String expected = "Frame " + prettyOutput ( ) + " is present, displayed, and focused" ; try { // wait for element to be present if ( isNotPresent ( action , expected , cantSelect ) ) { return ; } // wait for element to be displayed if ( isNotDisplayed ( action , expected , cantSelect ) ) { return ; } // select the actual frame WebElement webElement = getWebElement ( ) ; driver . switchTo ( ) . frame ( webElement ) ; } catch ( Exception e ) { log . warn ( e ) ; reporter . fail ( action , expected , cantSelect + prettyOutputEnd ( ) + e . getMessage ( ) ) ; return ; } reporter . pass ( action , expected , "Focused on frame " + prettyOutputEnd ( ) . trim ( ) ) ; }
Selects the frame represented by the element but only if the element is present and displayed . If these conditions are not met the move action will be logged but skipped and the test will continue .