public static String getXPathForColumnIndex(String columnName) {
        // determine how many columns are before the column with the requested name
        // the column with the requested name will have an index of the value +1 (since XPath indexes are 1 based)
        String headerXPath = getXPathForHeaderCellWithText(columnName);
        return String.format("count(ancestor::table[1]//tr/%1$s/preceding-sibling::th)+1", headerXPath);
    }
public static String getXPathForColumnIndex ( String columnName ) { String headerXPath = getXPathForHeaderCellWithText ( columnName ) ; return String . format ( "count(ancestor::table[1]//tr/%1$s/preceding-sibling::th)+1" , headerXPath ) ; }
Creates an XPath expression that will determine, for a row, which index to use to select the cell in the column
with the supplied header text value.
@param columnName name of column in header (th)
@return XPath expression which can be used to select a td in a row