-->

How to turn off popup blocker through code in Wati

2019-02-20 14:36发布

问题:

I am facing trouble in turning the popup blocker off through watin code. Could anyone please help me in knowing how to turn off the popup blocker of IE through watin? Is there any way to turn off the popup blocker of tool bars (like google, yahoo or msn) if any of them are installed in IE? Thanks for your help in advance.

回答1:

You can use .NET to change the registry keys for IE. See http://support.microsoft.com/kb/843016 for more information on the specific keys.

All:

HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_WEBOC_POPUPMANAGEMENT
Value = 0 for Off
Value = 1 for On

Per Zone:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\[0-4]\1809
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\[0-4]\1809
Value = 0 for Enabled
Value = 3 for Disabled

Per Site:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\New Windows\Allow
Create subkey with domain name and binary data.

Here is a code example of writing the registry keys through .NET to get a site into a trusted zone, which allowed WatiN to be able to download a file:

Programmatically add trusted sites to Internet Explorer



回答2:

You can't disable this with WatiN, you could however use UIAutomation to do it.