Anyone???
Following is my code, where I get list of data from the webtable. After I get the data How do I implement sort after I get the list?
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
import junit.framework.Assert;
import org.junit.Test;
import
org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class getdatafromawebtable {
static FirefoxDriver driver = new FirefoxDriver();
String BaseURL = “
https://qa.example.com/”;
int iwait = 3000;
@Test
public void sorting() throws Exception {
driver.get(BaseURL);
driver.findElement(By.id(“Username”)).sendKeys(“username”);
driver.findElement(By.id(“Password”)).sendKeys(“pswd”);
driver.findElement(By.xpath(“//input[@type=’input’]”)).click();
driver.findElement(By.xpath(“"xpath)).click();
WebElement table = driver.findElement(By.xpath(“//descendant::table[4]”));
List rows = table.findElements(By.tagName(“tr”));
int row_count = rows.size();
System.out.println(“Total rows is ” + row_count);
IteratorI1 = rows.iterator();
while(I1.hasNext()){
WebElement data = I1.next();
List columns= data.findElements(By.tagName(“td”));
Iterator I2=columns.iterator();
while(I2.hasNext()){
WebElement text=I2.next();
String columndata=text.getText();
System.out.print(” “);
System.out.print(columndata);
System.out.print(” “);
}
System.out.println(“”);
}
}
}