using System;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium;
namespace CSharpAutomationFramework.Tests
{
public class BrowserSource
{
var options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
public bool IgnoreZoomLevel { get; set; }
public bool IntroduceInstabilityByIgnoringProtectedModeSettings { get; set; }
InternetExplorerDriver protectivemode = new InternetExplorerDriver(options);
InternetExplorerOptions options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
InternetExplorerDriver zoom = new InternetExplorerDriver(zoomoptions);
InternetExplorerOptions zoomoptions = new InternetExplorerOptions();
options.IgnoreZoomLevel = true;
static string[] Browsers = {
"ie"
};
}
}
I am trying to use the above code to ignore zoom levels and Protective mode settings while running my selenium script but the script is displaying errors on building the solution. Not sure where i am going wrong.
While working with Selenium 3.x, IEDriverServer 3.x and Internet Explorer you can't ignore Zoom Levels and Protective Mode settings.
If you look into the Required Configuration of Internet Explorer Driver the folowing points are clearly mentioned :
Protected Mode
On Internet Explorer 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. The value can be on or off, as long as it is the same for every zone. To set the Protected Mode settings you have to choose "Internet Options" from the "Tools" menu and then click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled Enable Protected Mode.
@JimEvans in his article You're Doing It Wrong: IE Protected Mode and WebDriver clearly mentions :
Using the capability doesn't solve the underlying problem though. If a Protected Mode boundary is crossed, very unexpected behavior including hangs, element location not working, and clicks not being propagated, could result. To help warn people of this potential problem, the capability was given big scary-sounding names like
INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS
in Java andIntroduceInstabilityByIgnoringProtectedModeSettings
in .NET. We really thought that telling the user that using this setting would introduce potential badness in their code would discourage its use, but it turned out not to be so.
Browser Zoom Level
The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.
Solution
As per the Required Configuration of Internet Explorer Driver :
- Set/Unset the Protected Mode settings to the same level for all the Zones.
- Set the Browser Zoom Level to 100%
来源:https://stackoverflow.com/questions/49850465/internet-explorer-protective-mode-setting-and-zoom-levels