2014-10-18 78 views
4

我需要爲編寫的UI測試編寫功能,當首次打開瀏覽器Internet Explorer時禁用彈出窗口。那麼我怎麼能在c#上編程呢?是否需要編輯一些註冊? enter image description here啓動時如何禁用窗口IE

回答

1

基於http://www.petenetlive.com/KB/Article/0000175.htm我們應該設置一個註冊表項:

Windows註冊表編輯器5.00版

[HKEY_LOCAL_MACHINE \ SOFTWARE \政策\微軟\的Internet Explorer \ MAIN] 「DisableFirstRunCustomize」= DWORD:00000001

在C#

,我們應該能夠做到這一點,如:

var key = Registry.LocalMachine.OpenSubKey("SOFTWARE", true) 
    .OpenSubKey("Policies", true) 
    .OpenSubKey("Microsoft", true); 

    key = key.OpenSubKey("Internet Explorer", true) ?? key.CreateSubKey("Internet Explorer", RegistryKeyPermissionCheck.ReadWriteSubTree); 
    key = key.OpenSubKey("Main", true) ?? key.CreateSubKey("Main", RegistryKeyPermissionCheck.ReadWriteSubTree); 
    key.SetValue("DisableFirstRunCustomize", 1, RegistryValueKind.DWord);