public boolean findElementInTable(WebDriver driver, WebDriverWait wait, String text) { WebElement table = driver.findElement(By.xpath("//*[@id=\"skills\"]/tbody")); List<WebElement>rowsCltn = table.findElements(By.xpath("//*[@id=\"skills\"]/tbody/tr")); boolean found = false; if(rowsCltn.size() > 0) { String cell_text= ""; for(int i = 2; i<= rowsCltn.size(); i++) { cell_text = driver.findElement(By.xpath("//*[@id=\"skills\"]/tbody/tr[" +i +"]/td[1]")).getText(); if(cell_text.contains(text)) { found = true; break; } } } return found; } |