I have created a test case where I shall enter details for a deal to be scheduled for a future date and time. I have a pop up which is listing all existing deals having check boxes for selecting one of them independently. I could create and run the test case successfully only once but on further executions the first check box is always getting selected.
//steps to click on a check box
new WebDriverWait(driver, 100).until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//span[contains(.,'CAR')]")));
String s=driver.findElement(By.xpath("//span[contains(.,'CAR')]")).getAttribute("id");
int number=Integer.parseInt(s.split("_")[3]);
String chkboxid="AdminMainContent_grdDealDetails_chkSelect_"+number;
new WebDriverWait(driver, 100).until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.id(chkboxid)));
driver.findElement(By.id(chkboxid)).click();
//click on ok button
new WebDriverWait(driver,100).until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.id("AdminMainContent_lbtnOkGrid")));
driver.findElement(By.id("AdminMainContent_lbtnOkGrid")).click();
Thanks
