public void DuplicateLead(String LeadLastName) { new Leadlib().CreateLead(LeadLastName); wclib.waitForPageToLoad(); com.getMorebtn().click(); lead.getLeadDuplicateLink().click(); wclib.waitForPageToLoad(); com.getSavebtn().click(); wclib.waitForPageToLoad(); lead.getLeadListLink().click(); wclib.waitForPageToLoad(); List<WebElement> lst = wclib.GetBulkWebElementusingxpath( "//table[@class='table table-bordered listViewEntriesTable']/tbody/tr/td[3]"); int count = 0; for (int i = 1; i < lst.size(); i++) { String duplicatename = ((WebElement) lst.get(i)).getText(); if (LeadLastName.equals(duplicatename)) { count++; } else { System.out.println("Duplicate Leads is not created"); } } System.out.println(count + " " + "duplicate Leads is created"); }