从.NET内部控制Opera驱动程序

时间:2011-06-08 17:09:59

标签: c# .net opera webdriver

如何从.NET框架内控制Windows上的Opera Driver https://github.com/operasoftware/operadriver/(甚至Opera浏览器本身)?

我的目标是制作类似于Browsershots.org

的内容

1 个答案:

答案 0 :(得分:2)

最简单的方法是使用RemoteWebDriver,这需要Selenium服务器运行。代码看起来类似于以下内容(警告:未经测试的代码)。

// Assumes the Selenium server is running on port 4444 on localhost.
// Note that the Opera() method of the DesiredCapabilities class is
// not included in 2.0rc2 (the currently available binary release),
// but does exist in the trunk.
IWebDriver driver = new RemoteWebDriver("http://localhost:4444/wd/hub", DesiredCapabilities.Opera());