HomeSelenium C#

Selenium C# – Maximizing the Browser

Selenium C# – Maximizing the Browser

<<Previous Post                            << Complete Tutorial>>                              Next Post>>

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:

1) Launch Visual Studio and select an existing project which is already configured with Selenium and WebDriverManager as shown below:

Navigate URL - Launch Project

2) Write the WebDriverManager and ChromeDriver object creation statement as explained in the previous WebDriverManager post:

Navigate URL - ChromeDriver

3) Now let’s write the below Selenium code to navigate to http://omayo.blogspot.com/ as shown below:

driver.Navigate().GoToUrl("http://omayo.blogspot.com/");

Screenshot:

Navigate URL - Navigate

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:

Selenium C# - ThreadSleep

5) Let’s maximize the chrome browser page by adding driver.Manage().Window.Maximize()  to the code as shown below:

Selenium C# - Maximize Command

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:

Selenium C# - Maximized Browser

Here concludes this article.

In the next article, I will choose another Selenium command for performing different operation on the web page.

Next Steps:

  • > 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 ?

About Me > Naveen Repala

Connect to me on Linked In (Click here)

On a mission to contribute to the Software Testing Community in all possible ways.

<<Previous Post                            << Complete Tutorial>>                              Next Post>>

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *

For FREE Testing Tutorials & Videos

X
Open chat
Contact Us on Whatsapp