Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the URL of the current window using Selenium WebDriver in C#?

In my application when sign-in, then it navigates to another page. Now I need to get that new URL using WebDriver in selenium C#.

I can't find any function to do this. I have tried driver.Url, driver.getLocation() and driver.getCurrentUrl(), but nothing is working in my C# application. So is it possible get the current URL somehow? After it gets navigated?

like image 781
Dark Matter Avatar asked Oct 05 '16 13:10

Dark Matter


1 Answers

Yes, you can get the URL of the current page. Instantiate your driver and then get the driver's Url property.

Code snippet:

IWebDriver driver = new FirefoxDriver();
String currentURL =  driver.Url;

Help from: Selenium: Find the base Url

like image 148
optimistic_creeper Avatar answered Sep 24 '22 19:09

optimistic_creeper