How to maximize the browser window in Selenium WebDriver (Selenium 2) using C#?

前端 未结 28 2213
悲&欢浪女
悲&欢浪女 2020-11-29 18:20

Is there any way to maximize the browser window using WebDriver (Selenium 2) with C#?

28条回答
  •  [愿得一人]
    2020-11-29 18:28

    C# client drivers:

    driver = new FirefoxDriver(firefoxProfile);
    driver.Manage().Window.Size = new System.Drawing.Size(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width+10, System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height+10);
    

    ===> also add a reference to the .NET assembly "System.Windows.Forms"

    ... the only problem is that it's not positioned correctly
    ... please comment if you can correct this

提交回复
热议问题