In the previous article, I have practically demonstrated retrieving the Page Title using Selenium C#.
In this article, I am going to practically demonstrated retrieving the Current Page URL using Selenium C# API command Url.
Let’s get started.
Selenium C Sharp – Retrieving the Current Page URL
In this article, I am going to practically demonstrate by providing the task first followed by solution.
Task: Open the http://omayo.blogspot.com URL in Chrome browser and retrieve the Current Page URL of the page.
Solution: Lets follow the below steps:
2) Write the below code explained in the previous posts for navigating to the http://omayo.blogspot.com URL in chrome browser in maximized mode as shown below:
3) Now use the driver.Url to retrieve the title of the page and hover the mouse to see the return type of Url command as shown below:
4) Observe that the return type of Url is String, hence create a variable for String Class and assign the value retrieved by Url to the variable as shown below:
String url = driver.Url;
5) Print the above retrieved and stored title in the variable as shown below:
6) Save and click on ‘Start’ button to execute the above code.
Observe that the Selenium C# Script will get executed and the Current URL of the page will be retrieved and printed as shown below:
Here concludes this article.
In the next article, I will choose another Selenium command for performing different operation on the web page.
- > To learn more about Selenium C#, continue to the next post (Click on Next Post Link Below)
- > Check complete Selenium C# Tutorial Contents here (Click here)
Please leave your questions/comments/feedback below.
Happy Learning 🙂
On a mission to contribute to the Software Testing Community in all possible ways.