c# - 使用 Selenium WebDriver C# 最大化 Firefox 的浏览器窗口

标签 c# selenium firefox selenium-webdriver

对于 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 driver = new WebDriver ("www.google.com", capabilities); 

我尝试用 firefox.switches 替换 chrome.switches。对于 Mozilla Firefox,这不起作用。

谁能知道我怎样才能最大化打开网站?

最佳答案

对于 Firefox 使用 -

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

您可以查看此链接了解更多详情 - How do I maximize the browser window in Selenium WebDriver (Selenium 2) using C#?

关于c# - 使用 Selenium WebDriver C# 最大化 Firefox 的浏览器窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10649093/

相关文章:

c# - 在子类上创建默认构造函数

git - 如何配置 git help 以使用 Firefox?

firefox - 非 IE 浏览器的浏览器缓存 API

c# - XmlAttributeOverrides 进一步定制

c# - 有什么理由在接口(interface)中声明可选参数吗?

C# 将图像作为 blob 保存到 MySql 数据库

python Selenium "Chrome is being controlled by automated test software"

selenium webdriver 中的 css 或 xpath 正则表达式

selenium - 向 Selenium Docker 添加更多实例

html - 在包含 SVG 标记元素的页面上使用基本标记无法呈现标记