使用Selenium WebDriver最大化Firefox的浏览器窗口C#(Maximize browser window for Firefox with Selenium WebDriver C#)

其他开发 IT屋
问 题

For Chrome I have this code :

    List<String> capabilityValue = new List<string>();
    capabilityValue.Add("--start-maximized");
    capabilities = DesiredCapabilities.Chrome();
    capabilities.SetCapability("chrome.switches", capabilityValue);
    capabilities.Platform = new Platform(platform);
    WebDriver driver = new WebDriver ("www.google.com", capabilities); 

I try to replace chrome.switches with firefox.switches. For Mozilla Firefox this doesn't work.

Can anyone know how can I open site as maximized?

解决方案

For Firefox use -

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

You can check this link for more details - How do I maximize the browser window in Selenium WebDriver (Selenium 2) using C#?

本文地址:IT屋 » Maximize browser window for Firefox with Selenium WebDriver C#

问 题
对于Chrome我有这样的代码:

  List< String> capabilityValue = new List< string>(); 
capabilityValue.Add(“ - start-maximized”);
capabilities = DesiredCapabilities.Chrome();
capabilities.SetCapability(“chrome.switches”,capabilityValue);
capabilities.Platform = new Platform(platform);
WebDriver驱动程序=新的WebDriver(“www.google.com”,功能);


我尝试将 chrome.switches 替换为 firefox.switches 。



任何人都知道如何打开网站最大化?


解决方案

对于Firefox使用 - $ / $>
$ b

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


您可以查看此链接了解更多详情 - 如何使用C#最大化Selenium WebDriver(Selenium 2)中的浏览器窗口? / p>

本文地址:IT屋 » 使用Selenium WebDriver最大化Firefox的浏览器窗口C#