By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,248 Members | 1,961 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,248 IT Pros & Developers. It's quick & easy.

how can i get particular column data list in selenium?

P: 20
Expand|Select|Wrap|Line Numbers
  1. WebElement mytable = driver.findElement(By.id("resultTable"));
  2.             //To locate rows of table. 
  3.             List < WebElement > rows_table = mytable.findElements(By.tagName("td"));
  4.             //To calculate no of rows In table.
  5.             int rows_count = rows_table.size();
  6.             String rows_count1 = rows_table.get(3).getText();
  7.             System.out.println(rows_count1);
  8.             System.out.println(rows_count);
  9.             //Loop will execute till the last row of table.
  10.             for (int row = 0; row < rows_count; row++) {
  11.                 //To locate columns(cells) of that specific row.
  12.                 List < WebElement > Columns_row1 = rows_table.get(row).findElements(By.tagName("tr"));
  13.                 //To calculate no of columns (cells). In that specific row.
  14.                 int columns_count = Columns_row1.size();
  15.                 //ListIterator<WebElement> columns_count1 = Columns_row.listIterator(1));
  16.                 System.out.println("clo----->"+columns_count);
  17.                 System.out.println("Number of cells In Row " + row + " are " + columns_count);
  18.                 //Loop will execute till the last cell of that specific row.
  19.                 for (int column = 0; column < columns_count; column++) {
  20.                     // To retrieve text from that specific cell.
  21.                     String celtext = Columns_row1.get(column).getText();
  22.                     System.out.println(celtext);
  23.                 }
  24.                 System.out.println("-------------------------------------------------- ");
  25.             }
  26.  
i trying this code but its not getting proper result.
4 Weeks Ago #1
Share this Question
Share on Google+
1 Reply


zmbd
Expert Mod 5K+
P: 5,397
so... what is it that you were trying to fetch
and... what is it that you are getting

without that information it's a lot harder to help you
4 Weeks Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.