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

In my application, when I log in, I go to another page. Now I need to get this new URL using WebDriver in Selenium C #.

I can not find any function for this. I tried driver.Url , driver.getLocation() and driver.getCurrentUrl() , but nothing works in my C # application. So is it possible to get the current URL somehow? After it is done?

+8
source share
2 answers

Yes, you can get the url of the current page. Activate your driver, and then get the Url property of the driver.

Code snippet:

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

Help: Selenium: find the base URL

+17
source
 IWebDriver driver = new OpenQA.Selenium.IE.InternetExplorerDriver("C:\\"); Console.WriteLine("url "+ driver.Url); 

driver.Url gives you the current URL

0
source

Source: https://habr.com/ru/post/1257735/


All Articles