HomeSelenium C#

Selenium C# – Customizing the Browser Window Size

Selenium C# – Customizing the Browser Window Size

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

In the previous article, I have explained – Maximizing the Browser Window.

In this article, I will explain Customizing the Browser window to a particular size using driver.Manage().Window().Size

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:

Navigate URL - Navigate

4) Let’s customize the chrome browser size page by adding driver.Manage().Window.Size to the code along with required x and y coordinates as shown below:

The below is the code for assigning the x and y coordinates to the browser size as an argument:

Screenshot:

Selenium C# - Size

5)  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 displayed in customized size as per above the x and y coordinate arguments (i.e. 480 ad 320) as shown below:

Selenium C# - Customized Size

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

If you like this article, share it on LinkedIn using the below button:

Comments (0)

Leave a Reply

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