2013-08-22 26 views
0

因此,基本上我試圖找到所有隱藏的IE窗口,這對於LINQ應該是一件容易的事情。所以,我想一個簡單的地方:使用LINQ時,Watin IE變得可見,其中

var Instances = IE.InternetExplorers().Where(x => x.Visible == false); 

但是當我打電話InternetExplorers()它使所有的實例可見,並得到任何結果。 所以我嘗試到不同的地方:

var Instances = IE.InternetExplorers().Where(x => x.Title != ""); 

這也使得所有實例可見,但顯然得到所有打開的IE窗口。

那麼有沒有一種方法可以選擇所有不可見但未顯示的實例,或者我是否做錯了什麼?

+0

你調用'InternetExplorers()'必須設置所有實例可見。 –

+0

是的,這是真的,所以有一種替代方法來獲得所有的實例。 –

回答

0

我找到了答案,我看着華廷source,發現InternetExplorers()方法只返回new IECollection(true);所以我看着IECollectionconstructor,發現WatiN.Core.Native.InternetExplorer.ShellWindows2()回報所有的瀏覽器。

所以最終我這樣做:

var allBrowsers = new WatiN.Core.Native.InternetExplorer.ShellWindows2().Where(x => x.Visible == false); 

foreach (SHDocVw.IWebBrowser2 internetExplorer in allBrowsers) 
{ 
    //do somthing. 
}