Fetching URL of webpage

Hi
I have scenario where in I have to click on Link, it opens a new web page and then i need to fetch the URL of that newly opened Web page.
Can anyone suggest how to do it in web automation.

Just for more clarification, do you only need URL in text format and also, could you please check one point that whenever there is a link there is a reference of next url in it, please try to find that reference.

If not, please share link which you’re working on.

Yes, I need the URL in text format so that it can be saved in File.

Also ,Can you elaborate on “reference of next URL” ?

The “reference of next URL" means the attribute href (reference) in anchor tag.
For example, < a href=“www.abc.com”>abc< /a>

Here, abc is the value of attribute href that means whenever you click on abc it redirects to “www.abc.com”.

You can get this url by using getAttribute(“href”) to a specific Xpath.

How do you use this? Use it as Get Value in the XPath column?

You have to code this in User Defined Java class.

For Example: String Link_Text = driver.findElement(By.xpath("//*[@id=‘gbw’]/div/div/div[1]/div[1]/a")).getAttribute(“href”);