Open Browser Window in Full Screen Using Selenium WebDriver



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: 2021-04-07T08:13:21+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements