Searching...
Sunday, 30 December 2012

Handling Web Tables in Selenium RC

Handling Web Tables in Selenium RC

1. Read data from table in specified row and column
String Str=selenium.getTable("locator.row.column");


2. Read selected data from table
// match for matching the required row
String match,value;

// First find the no of rows by counting the no of tr
int rows=selenium.getXpathCount("//*[@id=' ']/body/tr").intValue();

// Find no of columns by counting the number of td's under tr's
int columns=selenium.getXpathCount("//*[@id=' ']/body/tr/td").intValue();

for (i=1;i<rows;i++)
{
match=selenium.getTable("locator."+i+".0").trim();
if (match.equals("Matchingvalueinrow"))
{
for(j=0;j<columns;j++)
{
value=selenium.getTable("locator."+i+"."+j);
}
break;
}
}


Commands used for tables :
  1. getXpathCount().intValue() --- To get the number of rows and columns.
  2. getTable() --- To get the content of table


2 comments:


  1. Hello author,

    I found your blog while searching for the updates in Selenium WebDriver,I am happy to be here. Very useful content and also easily understandable providing.. Believe me I did wrote an post about selenium tutorials for beginners with reference of your blog.

    ReplyDelete

 
Back to top!