Web table implementation in POM with Page factory | Selenium Forum
R
Rajyalakshmi Gubbala Posted on 30/11/2020

Hi,

In general we will use findelements(By.xpath) would be used. But for in page factory please let me know which annotation should be used to extract webtable rows and column.

 

Ex below code trying to get all column names from webtable. getting null pointer exception. My requirement here is to get all column values and retun. Please advice

@FindBy(xpath="//mat-table/mat-header-row/mat-header-cell")
List<WebElement> resultstableheader;

 

Method:

L public void refundSearchResultsHeadervalues() {

List<WebElement> headervalues = resultstableheader;


System.out.println("Headers in table are below:");
System.out.println("Total headers found: "+headervalues.size());
for (int i = 1; i < headervalues.size(); i++)

{

System.out.println(headervalues.get(i).getText());
}


}


A
Ashish Thakur Replied on 01/12/2020

@FindBys can find multiple elements

 

@FindBys(xpath="//table[@id='x']/tr") - for all table rows


Related Posts