"Karmanyevadhikaraste ma phaleshu kadachana, Ma karma phala hetur bhurmatey sangostva akarmani."

Element present at xpath

public boolean isElementPresent_xpath(String objectXpath){
int count=driver.findElement(By.xpath(objectXpath)).size();
if(count==0)
return false;
else
return true;


String firstname="Meeraj";
String lastname="Anasuri";
Assume names are in  a web table,
//Validations:

String part1="//*@id='hkjhjkh[" ;
String part2="]/td[2]";
int i=2 // as xpath starts at 2 for this
while( isElementPresent_xpath(part1+i+part2))
String fname=driver.findElement(By.xpath(part1+i+part2).getText();
if(fName.equals(firstname)){

//then check for last name

String xpathLastnamecol= part1+i+part2.replace("td[1]","[2]");
String lName=driver.findElement(by. xpathLastnamecol).getText();
if(lName.equals(LastName)){
system.out.println();
recordFound=true;
break;
}}

Assert.assertTrue(recordFound,"Record of full name");