Merge Lead
~30 mins
Merge Lead
package testcase;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import io.github.bonigarcia.wdm.WebDriverManager;
public class MergeLead extends BaseClass{
public void runMergeLead() throws InterruptedException {
driver.findElement(By.linkText("Merge Leads")).click();
driver.findElement(By.xpath("//img[@alt='Lookup']")).click();
Set<String> allWindows = driver.getWindowHandles();
List<String> allhandles = new ArrayList<String>(allWindows);
driver.switchTo().window(allhandles.get(1));
driver.findElement(By.xpath("//input[@name='firstName']")).sendKeys("gopi");
driver.findElement(By.xpath("//button[text()='Find Leads']")).click();
Thread.sleep(1000);
String leadID = driver.findElement(By.xpath("//div[@class='x-grid3-cell-inner x-grid3-col-partyId']/a")).getText();
driver.findElement(By.xpath("//div[@class='x-grid3-cell-inner x-grid3-col-partyId']/a")).click();
driver.switchTo().window(allhandles.get(0));
driver.findElement(By.xpath("(//img[@alt='Lookup'])[2]")).click();
Set<String> allWindows2 = driver.getWindowHandles();
List<String> allhandles2 = new ArrayList<String>(allWindows2);
driver.switchTo().window(allhandles2.get(1));
driver.findElement(By.xpath("//input[@name='firstName']")).sendKeys("babu");
driver.findElement(By.xpath("//button[text()='Find Leads']")).click();
Thread.sleep(1000);
driver.findElement(By.xpath("//div[@class='x-grid3-cell-inner x-grid3-col-partyId']/a")).click();
driver.switchTo().window(allhandles2.get(0));
driver.findElement(By.xpath("//a[text()='Merge']")).click();
driver.switchTo().alert().accept();
driver.findElement(By.linkText("Find Leads")).click();
driver.findElement(By.xpath("//input[@name='id']")).sendKeys(leadID);
driver.findElement(By.xpath("//button[text()='Find Leads']")).click();
String text = driver.findElement(By.className("x-paging-info")).getText();
if (text.equals("No records to display")) {
System.out.println("Text matched");
} else {
System.out.println("Text not matched");
}
driver.close();
}
}