-->

Hiding Internet Explorer when WatiN is run

2019-01-17 17:39发布

问题:

I would like to know how I can prevent Internet Explorer from firing up every time I run my console application which uses WatiN for testing live sites.

When I run my console application it fires up internet explore and runs through all the tests that I have created using WatiN.

What I want is for my console application to run through these tests using WatiN, but without displaying Internet Explorer starting up and appearing on the screen.

I basically want the tests to run without seeing Internet Explorer.

回答1:

The IE class by deafult uses some built in settings for a few features. One of which is MakeNewIeInstanveVisible. By default it is set to true. So you can change the WatiN Settings before you create a new instance of the IE class.

Settings.Instance.MakeNewIeInstanceVisible = false;


回答2:

Try:

using (IE ie = new IE("http://somesite.com/"))
{
  ie.ShowWindow(NativeMethods.WindowShowStyle.Hide);
  ....
}


回答3:

browser.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Hide);