public static String getXPathForHeaderRowByHeaders ( String columnName , String ... extraColumnNames ) { String allHeadersPresent ; if ( extraColumnNames != null && extraColumnNames . length > 0 ) { int extraCount = extraColumnNames . length ; String [ ] columnNames = new String [ extraCount + 1 ] ; columnNames [ 0 ] = columnName ; System . arraycopy ( extraColumnNames , 0 , columnNames , 1 , extraCount ) ; allHeadersPresent = Stream . of ( columnNames ) . map ( GridBy :: getXPathForHeaderCellWithText ) . collect ( Collectors . joining ( " and " ) ) ; } else { allHeadersPresent = getXPathForHeaderCellWithText ( columnName ) ; } return String . format ( "/tr[%1$s]" , allHeadersPresent ) ; }
Creates an XPath expression that will find a header row selecting the row based on the header texts present .