Navigation Commands In Selenium WebDriver: In our previous posts we have discussed so many articles on different topics like Different locators in Selenium WebDriver, How to setup Eclipse project and How to Run your first Selenium program like this. In this post, we are going to discuss the different navigation commands.
After successfully run the first selenium program, now we can proceed to learn about the various navigational commands. So in this post, we have the plan to share the different navigation common which we are using a regular basis in our automation testing script. A browser has various options for navigation, like:
- Open a Web Page URL
- Navigate to another web page by Clicking any element
- Go Back
- Go forward
- Refresh a web page
Let us go through each of the commands one by one and learn how to do with the help of using Selenium WebDriver.
Navigate.To(URL): Open a URL
In our previous, we have seen that by the help of using the get() method, we can able to open a web page url. But in Navigation interface also have one to() method open any web page url.
Navigate.Back():
This method will load a new web page on the current browser window. All the process is done with the help of the Get operation, and this method will block all other option until the load process is complete.
Note: The url should be a full url
Add a Link of Difference between Get() and TO() method
Add a Program
Navigate to another web page by Clicking any element:
We can achieve this by locating any clickable element by using the locators of Selenium webDriver. If you don’t know, then you can read our previous posts on different locators on selenium.
Navigate.Back():
If you have redirected to other pages (Inner page) from a Home page and you have completed your required operation on the redirected page (Inner page), and again you want to go back to the home page. Then, in that case, you can use the back() method of Navigate interface.
This method moves back a single page ion the web history, and if you are in the home page, then this method will not perform any action.
Add Program
Navigate.Forward():
Like the back() method we can use the forward() method when our requirement is to move one page forward in the web history. It will not perform any operation if you are in the last or latest page of web history.
Add a Program
Navigate.Refresh():
If your requirement is reloading the complete page then in navigate interface we have a method called refresh(). You can use this method to refresh the complete web page.
Add a Program
Leave a Reply