2009-12-20 46 views
2

我要檢查如果IE已打開或不檢查打開瀏覽器中使用華廷

If IE is opened so i.e. Goto("WWW.GOOGLE.COM"); 
else open new IE and goto Yahoo.com 

例如:

br = new WatiN.Core.IE(@textBox1.Text); 

然後當我按下一個按鈕,我想檢查IE是否打開,並執行之前的情形。

回答

4

用途:

IE.Exists(Find.ByUrl("Yahoo.com")); 

在華廷2.0 RC1,這將是:

Browser.Exists<IE>(Find.ByUrl("Yahoo.com")); 
+0

謝謝您的回覆, 但我想,以檢查由(BR),但 打開的IE實例IE.Exists(Find.ByUrl( 「Yahoo.com」));如果有手動打開一個IE實例,並且具有相同的URL 會也返回true。 – 2009-12-22 11:33:24

+0

在這種情況下,也許這代碼/想法可能幫助http://watinandmore.blogspot.com/2009/03/reusing-ie-instance-in-vs-test.html – 2009-12-30 13:28:23