Hi,
Please help me during handle the web table dynamically.
[b:1y65cy9n]IT DISPLAY ALL THE RECORDS EVEN I GIVE THE CONDITION IF CONDITION IS MATCH THAN BREAK THE LOOP AND STOP.[/b:1y65cy9n]
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.firefox.FirefoxDriver;
public class WebTable2 {
public static void main(String[] args) {
String number ="184.75";
WebDriver driver = new FirefoxDriver();
//driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://money.rediff.com/gainers/bse/daily/groupa?src=gain_lose");
int row = driver.findElements(By.xpath("//table[@class='dataTable']/tbody/tr")).size();
int column =driver.findElements(By.xpath("//table[@class='dataTable']/tbody/tr[1]/td")).size();
System.out.println("Total Rows And Columns Are --- > " +row +" ---> "+ column);
for(int rowNum=1;rowNum<=row;rowNum++){
List<WebElement> rowCell = driver.findElements(By.xpath("//table[@class='dataTable']/tbody/tr["+rowNum+"]/td"));
for(int cellnum=0;cellnum<rowCell.size();cellnum++){
System.out.print(rowCell.get(cellnum).getText() + "----------");
if(number.equals(rowCell.get(cellnum).getText())){ =====>>>> [b:1y65cy9n]System is match the condition in IF loop even after the BREAK command it continuously display the records in CONSOLE it should be stop if the condition is match i.e. if code match the number with "184.75". [/b:1y65cy9n]
System.out.println("Data Value Match And Record is --- > " + rowCell.get(cellnum).getText());
break;
}
}
System.out.println();
}
}
}