Selenium Get Current URL

Profile picture for user arilio666

To get the current page's URL, we can fetch the name from the getCurrentUrl() method in selenium.


Let's have a look at how it works.

package week4.day2;
import io.github.bonigarcia.wdm.WebDriverManager;
public class DropDown {
    public static void main(String[] args) throws InterruptedException {
        ChromeDriver driver = new ChromeDriver();
        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.