package tableAutomation;
import org.testng.annotations.Test;
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;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.BeforeTest;
public class SearchData {
WebDriver driver;
@Test
public void DisplaySeachRow() throws Exception {
driver.get("http://www.seleniumlearn.com/table");
driver.manage().timeouts().implicitlyWait(19, TimeUnit.SECONDS);
Thread.sleep(3000);
WebElement table=driver.findElement(By.xpath("//table"));
List<WebElement> rows = table.findElements(By.xpath("//tr"));
List<WebElement> columns = table.findElements(By.xpath("//th"));
System.out.println("=============Search Details Data=================");
for(int td=0;td<rows.size();td++)
{
String word = "40000";
String text = rows.get(td).getText();
Boolean found;
found = text.contains(word);
if(found != false )
System.out.println(rows.get(td).getText());
}
}
@BeforeTest
public void beforeTest() {
driver=new FirefoxDriver();
// System.setProperty("webdriver.chrome.driver","D:\\lib\\chromedriver.exe"); //---> Chromedriver path
// driver = new ChromeDriver();
driver.manage().window().maximize();
}
}