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?
Asked
Active
Viewed 1,517 times
1 Answers
6
This is simple to accomplish with WatiN.
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)

Googer
- 271
- 1
- 3
-
1Another note to this - if your library call returns before the Firefox browser is fully initialized and loaded, depending on just how much later your Firefox window opens, you may find the default timeout of WatiN is too short. You can increase the timeout for WatiN attaching to a browser with the static `Settings` parameters - i.e., `Settings.AttachToBrowserTimeOut = 60;` to wait a minute (default timeout IIRC is 30 seconds). – Googer Aug 13 '12 at 14:55
-
1Thanks. It looks promising. I will try it. – muzieh Aug 13 '12 at 20:21
-
Unfortunately you can use WatiN with Firefox 3.6 or older. – muzieh Aug 27 '12 at 12:57