Without using the driver.close() the webdriver closes the browser window in Selenium 4. I want the browser to remain opened until I say driver.close().
After executing my code the Selenium Webdriver should not close the browser. The web browser should be opened until I call the driver.close() or driver.quit(). Is there any option to keep the browser opened. I am using Selenium 4 with Java 17.
import java.time.Duration;
import org.openqa.selenium.WebDriver;
import io.github.bonigarcia.wdm.WebDriverManager;
public class CloseBrowserTest_1
{
static WebDriver driver = null;
public static void main(String[] args) throws InterruptedException
{
driver = WebDriverManager.chromedriver().create();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
driver.manage().deleteAllCookies();
driver.get("https://www.google.com");
System.out.println("Title : " + driver.getTitle());
System.out.println("Current URL : " + driver.getCurrentUrl());
}
}