How to open a browser window in full screen using Selenium WebDriver with C#?


We can open a browser window in full screen using Selenium webdriver in C# by using the method Maximize. This method has to be applied on the webdriver object.

Syntax

driver.Manage().Window.Maximize();

Example

using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using System;
namespace NUnitTestProject1{
   public class Tests{
      String url = "https://www.google.com/";
      IWebDriver driver;
      [SetUp]
      public void Setup(){
         //object of FirefoxDriver
         driver = new FirefoxDriver();
      }
      [Test]
      public void Test1(){
         //URL launch
         driver.Navigate().GoToUrl(url);
         //browser maximize
         driver.Manage().Window.Maximize();
         Console.WriteLine("Browser Maximized");
      }
      [TearDown]
      public void closeBrowser(){
         driver.Quit();
      }
   }
}

Output

Updated on: 07-Apr-2021

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements