To get the current page's URL, we can fetch the name from the getCurrentUrl() method in selenium.
driver.getCurrentUrl();
Let's have a look at how it works.
package week4.day2;
import org.openqa.selenium.chrome.ChromeDriver;
import io.github.bonigarcia.wdm.WebDriverManager;
public class DropDown {
public static void main(String[] args) throws InterruptedException {
WebDriverManager.chromedriver().setup();
ChromeDriver driver = new ChromeDriver();
driver.get("http://programsbuzz.com/user/login");
driver.manage().window().maximize();
System.out.println("Current Page URL Is: " + driver.getCurrentUrl());
}
}

We can see here that this method fetched the page's current URL name and printed it as requested.