i wrote the code for the getting the text from the all the rows and columns
package WebTable_Handling;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Webtable_operations {
public static WebDriver driver;
public static void main(String[] args) {
// finding the totoal no. of rows
System.setProperty("webdriver.chrome.driver", "./exe files/chromedriver.exe");
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("file:///E:/Tushar/NCSM8.html");
List<webelement> rows = driver.findElements(By.xpath("//table[@name='Num']//tr['+']"));
int rowcount = rows.size();
System.out.println(rowcount);
//finding the numbers of columns in the webtable
List<webelement> columns = driver.findElements(By.xpath("//table[@name='Num']//tr['i+']/td"));
int column_count = columns.size();
System.out.println(column_count);
//getting the data from the webtables
for(int i=0;i<=rowcount;i++)
{
//WebElement wb = columns.get(i);
String data = rows.get(i).getText();
System.out.println(data);
}
}
}
it is giving me exceptions like arrayindexof bounds
What I have tried:
i have tried:
for(int i=0;i<rowcount;i++)
{
String data = rows.get(i).getText();
System.out.println(data);
}