将Selenium WebDriver附加到已打开的Firefox

muz*_*ieh 1 .net selenium integration-testing selenium-webdriver

我正在为C#库进行集成测试.我测试的.NET代码中的一个步骤是使用正确的url地址打开Firefox.我的集成测试应该为我的库提供一些数据,等待firefox启动并检查网页是否包含正确的数据.要使用硒,我必须以某种方式附加到由我的库提供的firefox.硒有可能吗?还有其他图书馆可以帮助我吗?

Goo*_*ger 6

使用WatiN很容易实现.

解释附加到现有浏览器的文档在这里.

您在测试中需要做的事情的主旨是连接到您的图书馆打开的浏览器基本上是:

// make library call that creates Firefox here
// ...

var browser = Browser.AttachTo<Firefox>(Find.ByUrl(MyUrl)); // or use another way of finding your browser instance if you wish

// do tests with browser variable using WatiN's API (an obvious first step is to fail test if browser is null)
Run Code Online (Sandbox Code Playgroud)