protected Locator byHeader ( int colIndex ) { if ( colIndex < 1 ) { throw new IllegalArgumentException ( "Column index must be greater than 0." ) ; } String xpath = headerTag . isPresent ( ) ? "./thead/tr[1]/th[" + colIndex + "]" : "./tr[1]/th[" + colIndex + "]" ; return byInner ( By . xpath ( xpath ) ) ; }
Conveniently allows column implementations to lookup headers without duplicating the effort to come up with xpath for each column s header . Simply use this method with that column s index .