In the previous article, I have practically demonstrated refreshing the page using Selenium C# API Command – Refresh().
In this article, I am going to practically demonstrated closing the browser window using Selenium C# API command Close().
Let’s get started.
Selenium C Sharp – Closing the Browser using Close()
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, halt the program for 5 seconds and then close the Browser window.
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) Write the below code for halting the program for 5 seconds for demonstration purpose as shown below:
4) Now write the Close() command as shown below:
5) Save and click on ‘Start’ button to execute the above code.
Observe that the Selenium C# Script will get executed and the following will happen in sequence:
- Application URL will open in Chrome Browser in Maximized mode
- Program will halt for 5 seconds
- Browser page will be closed
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.