Selenium Java to get the present browser URL
GD.java
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; class GD { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "/home/godarda/drivers/chromedriver"); WebDriver driver = new ChromeDriver(); driver.get("https://godarda.in/testapp/"); String currentURL = driver.getCurrentUrl(); System.out.println(currentURL); driver.close(); } }
Output
https://godarda.in/testapp/
Comments and Reactions
What Next?
Selenium Java to get the page source of a URL
Selenium Java to get the title of a given webpage
Selenium Java to compare the title of a given webpage
Advertisement