public int getNumberOfColumns ( ) { List < WebElement > cells ; String xPath = getXPathBase ( ) + "tr" ; List < WebElement > elements = HtmlElementUtils . locateElements ( xPath ) ; if ( elements . size ( ) > 0 && getDataStartIndex ( ) - 1 < elements . size ( ) ) { cells = elements . get ( getDataStartIndex ( ) - 1 ) . findElements ( By . xpath ( "td" ) ) ; return cells . size ( ) ; } return 0 ; }
Returns the number of columns in a table . If the table is empty column count cannot be determined and 0 will be returned .