I have 1 3rd party integration as Paypal. When I will click on Place Order button it will navigate me from Place Order page to paypal page. Can you please let me know how it will be work. I have tried below code and I will redirect to Paypal Page but new window gets appears instead of same page. Please let me know how I will able to stay on same screen.
String handle= driver.getWindowHandle();
System.out.println(handle);
driver.findElement(By.name("New Message Window")).click();
Set handles = driver.getWindowHandles();
System.out.println(handles);
for (String handle1 : driver.getWindowHandles()) {
System.out.println(handle1);
driver.switchTo().window(handle1);
}