Selenium Java to get the present browser URL
KW.java
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

class KW
{
    public static void main(String[] args) 
    {   
        System.setProperty("webdriver.chrome.driver", "/home/kodingwindow/drivers/chromedriver");
        WebDriver driver = new ChromeDriver();
        driver.get("https://kodingwindow.com/testapp/");
        String currentURL = driver.getCurrentUrl();
        System.out.println(currentURL);
        driver.close();
    }
}
Output
https://kodingwindow.com/testapp/
Advertisement