附加webdriver的硒对火狐已经打开火狐、webdriver

2023-09-04 04:09:22 作者:心语

我工作的集成测试的C#库。其中一个被测试在我的.NET code的步骤是打开火狐适当的URL地址。我的集成测试应该提供一些数据,我的图书馆,等待火狐将推出,并检查该网页所包含正确的数据。要使用硒我必须以某种方式连接到Firefox正在吃午饭我的图书馆。是否有可能与硒?是否有任何其他图书馆,可以帮助我吗?

I'm working on integration test for C# library. One of the steps in my .NET code being tested is to open Firefox with proper url address. My integration test should provide some data to my library, wait for firefox to be launched and check if the web page contains proper data. To use selenium I have to attach somehow to firefox being lunched by my library. Is it possible with Selenium? Are there any other libraries which could help me?

推荐答案

这是容易做到与华廷。

文档,解释附加到现有的浏览器是这里。

Documentation that explains attaching to an existing browser is here.

什么,你就需要在您的测试附加到开辟库中的浏览器做虽然要点基本上是:

The gist of what you'd need to do though in your test to attach to the browser opened up by your library is basically:

// 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)
 
精彩推荐
图片推荐