Hiding Internet Explorer when WatiN is run

2019-01-17 17:08发布

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.

3条回答
霸刀☆藐视天下
2楼-- · 2019-01-17 17:42

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;
查看更多
叼着烟拽天下
3楼-- · 2019-01-17 17:47

Try:

using (IE ie = new IE("http://somesite.com/"))
{
  ie.ShowWindow(NativeMethods.WindowShowStyle.Hide);
  ....
}
查看更多
疯言疯语
4楼-- · 2019-01-17 17:55
browser.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Hide); 
查看更多
登录 后发表回答