In the previous article, I have explained how to navigate to any URL using Navigate().GoToURL().
Similarly, in this article, I am going to practically demonstrate navigating to the given URL using the Selenium C# API commands Url and Navigate() method.
Let’s get started.
Selenium C# – URL navigation using Url and Navigate()
In this article, I am going to practically demonstrate by providing the task first followed by solution.
Task: Navigate to http://omayo.blogspot.com/ using Selenium C#
Solution: Lets follow the below steps:
2) Write the WebDriverManager and ChromeDriver object creation statement as explained in the previous WebDriverManager post:
3) Let’s set the URL using the Url predefined variable of Selenium C# API as shown below:
driver.Url = "http://omayo.blogspot.com/";
And then use the Navigate() method as shown below, to navigate to the above specified URL:
4) Save and click on ‘Start’ button to execute the above code.
Observe that the Selenium C# Script will get executed and the launched chrome browser will be navigated to the given URL as shown below:
Note: Make sure that you provide the complete URL into the Url predefined variable, as the URL like www.omayo.blogspot.com without http protocol wont work and will give you the ‘invalid argument error as shown below:
Hence provide the proper URL into the Url predefined variable for navigating to the desired web page.
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.