In the previous articles, I have explained – Navigating to URLs using Selenium C Sharp.
In this article, I am going to practically demonstrate Maximizing the browser using the Selenium C Sharp API Command Manage(), Window and Maximize().
Let’s get started.
Selenium C# – Maximizing the Browser
In this article, I am going to practically demonstrate by providing the task first followed by solution.
Task: Open the Chrome browser using Selenium C#, which opens the Browser in resized mode.
Wait for 5 seconds using Thread.Sleep() and then Maximize the browser using Manage(), Window and Maximize() Selenium C# API Commands.
Then navigate to http://omayo.blogspot.com URL using the previous explained Navigate().GoToURL()
Solution: Lets follow the below steps:
2) Write the WebDriverManager and ChromeDriver object creation statement as explained in the previous WebDriverManager post:
3) Now let’s write the below Selenium code to navigate to http://omayo.blogspot.com/ as shown below:
4) For demonstration purpose add the Thread.Sleep(5000) for halting the Automation code for 5 seconds after opening the chrome browser in the default resized mode as shown below:
5) Let’s maximize the chrome browser page by adding driver.Manage().Window.Maximize() to the code 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 observe that the Chrome browser will be maximized after 5 seconds 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.