Lets understand how we can do different types of navigation in a browser using the Browser Navigation Commands of IWebDriver implementation. IWebDriver interface is implemented by all the supported browser classes, hence you will find these navigation commands in all browsers. We are going to discuss about various navigation commands that we would be using in our day to day automation testing. The INavigation interface exposes the ability to move backwards and forwards in the browser’s history.
To access the navigation’s method, just type IWebDriver.navigate().. If you are using Visual studio or any IDE which supports intellisense, you will see the list of available navigation commands that you can use. Below is the image showing all the commands
We have four Navigation commands
This command is used to navigate to a particular page. Signature of this command is
void INavigation.GoToUrl(Stringurl) : This command takes a String value of the URL as input parameter and returns void. Once this statement is executed browser navigates to the new page specified by the URL parameter.
Command – driver.Navigate().GoToUrl(appUrl);
Where appUrl is the website address to load. It is best to use a fully qualified URL.
Back command is used navigate to the previous page in the browser history. This is exactly similar to what happens when you click on the back button in your browser.
void INavigation.Back() : This command does not take any parameter.
Takes youback by one page on the browser’s history.
Forward command is used to navigate to the next page in the browser history. This exactly similar to what happens when you click on the forward button in your browser, if you have some history in forward direction
void INavigation.Forward() : This command does not takes any parameter.
Takes you forward by one page on the browser’s history.
This command refreshes the page as if you have pressed F5 on the browser.
void INavigation.Refresh() : This command does not takes any parameter
static void Main(string args)
IWebDriver driver = new InternetExplorerDriver(@"C:\Users\abc\Desktop\Server");