如何使用C#在Selenium WebDriver(Selenium 2)中最大化浏览器窗口? [英] How to maximize the browser window in Selenium WebDriver (Selenium 2) using C#?
本文介绍了如何使用C#在Selenium WebDriver(Selenium 2)中最大化浏览器窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用WebDriver(Selenium 2)和C#最大化浏览器窗口?
Is there any way to maximize the browser window using WebDriver (Selenium 2) with C#?
推荐答案
将此功能添加到WebDriver存在一个突出的问题,可以在此处进行跟踪:
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#在Selenium WebDriver(Selenium 2)中最大化浏览器窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文