The HTML Section is -
I need to select the checkbox shown in the image based on the firstname and lastname value passed to the function
This is what I have written and it is helping me to click on the hyperlink of the lastname but I need to select the checkbox which is present in front of the
public void selectEmpFromList(String firstName, String middleName, String lastName, boolean checkOrUncheck) throws UIAutomationException {
try{
boolean flag = false;
//WebElement webElement = elementController.waitForWebElement(BrowserDriver.getBrowserDriver(), null, false, "EmployeeTable");
//List<WebElement> gridRow = elementController.waitForWebElements(BrowserDriver.getBrowserDriver(), webElement, false, "ClientsGridData");
elementController.setWebelement(elementController.waitForWebElement(BrowserDriver.getBrowserDriver(),null,false,"EmployeeTable"));
elementController.setWebelements(elementController.waitForWebElements(BrowserDriver.getBrowserDriver(),elementController.getWebelement(),false,"tagtr"));
// Loop until we get the current web element for the folder
for(int tr=0;tr<elementController.getWebelements().size();tr++)
{
WebElement firstColumn =elementController.waitForWebElement(BrowserDriver.getBrowserDriver(), elementController.getWebelements().get(tr), false, "firstColumn");
if(firstColumn.getText().toString().trim().equalsIgnoreCase(firstName))
{
WebElement lastColumn =elementController.waitForWebElement(BrowserDriver.getBrowserDriver(), elementController.getWebelements().get(tr), false, "lastcolumn");
if(lastColumn.getText().toString().trim().equalsIgnoreCase(lastName))
{
//lastColumn.click();
//WebElement checkbox = tableRows.get(count).findElement(By.xpath("td[1]"));
commonUI.clickOnCheckBox("EmpCheckBox", true);
flag = true;
break;
}
}
}
if(!flag)
{
System.out.println("Not found");
}
}catch(Exception exception) {
throw new UIAutomationException("Unable to select an employee from the record list. [clickOnSaveButton()]: " + exception.getMessage());
}
The xpath used for table n firstname n lastname are
<Element title="lastcolumn">
<xpath>td[4]/a</xpath>
</Element>
<Element title="firstColumn">
<xpath>td[3]/a</xpath>
</Element>
<Element title="EmployeeTable">
<xpath>//table[@id='resultTable']/tbody</xpath>
</Element>
Could you please suggest me the xpath for checkbox or the logic for what should be used for checking the checkbox??
RépondreSupprimerThis is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.
Selenium Training in chennai | Selenium Training in anna nagar | Selenium Training in omr | Selenium Training in porur | Selenium Training in tambaram | Selenium Training in velachery