我如何使用C#浏览器窗口最大化硒的webdriver(硒2)? [英] How do I maximize the browser window in Selenium WebDriver (Selenium 2) using C#?

查看:191
本文介绍了我如何使用C#浏览器窗口最大化硒的webdriver(硒2)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法最大限度地使用的webdriver(硒2)用C#浏览器窗口?

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

推荐答案

还有一个悬而未决的问题添加此功能的webdriver,可以在这里跟踪: http://code.google.com / p /硒/问题/细节?ID = 174

There's an outstanding issue to add this functionality to WebDriver, which can be tracked here: http://code.google.com/p/selenium/issues/detail?id=174

一个解决方法是使用 JavascriptExector 如下:

A workaround would be to use the JavascriptExector as follows:

public void resizeTest() {
    driver.Navigate().GoToUrl("http://www.example.com/");
    ((IJavascriptExecutor)driver).executeScript("window.resizeTo(1024, 768);");
}

这篇关于我如何使用C#浏览器窗口最大化硒的webdriver(硒2)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆